Page 1 of 1
How to resize *.png picture with auto-adjustment?
Posted: 2014-03-17T00:54:42-07:00
by bensto
Assume I have an original *.png picture with an unknown (big) width and height.
Now I want to resize/shrink it to a height of 800pixel.
The width should be automatically adjusted so that the height/width ratio of the original picture is kept.
In other words if for one particular PNG picture the height is shrinked to 62% then the width should be shrinked to 62% as well.
How would such a cmdline command look like?
The original PNG picture file should be replaced by the new one.
Is your suggested command picture format independent? read: Can I apply it to JPG pictures as well?
Ben
Re: How to resize *.png picture with auto-adjustment?
Posted: 2014-03-17T01:08:01-07:00
by snibgo
Code: Select all
convert picture.png -resize x800 picture.png
Instead of ".png", use any format you want.
Note: if picture.png is smaller that 800 pixels high, it will be enlarged to that height. To prevent this, use:
Code: Select all
convert picture.png -resize "x800>" picture.png
This works in Windows. Unix may need a different escaping mechanism for the ">" character.
See:
http://www.imagemagick.org/script/comma ... php#resize
http://www.imagemagick.org/script/comma ... p#geometry
Re: How to resize *.png picture with auto-adjustment?
Posted: 2014-03-17T03:15:11-07:00
by bensto
Thank you.
Regarding JPG one more question:
At which compression level will the conversion take place (by default)?
How do I specify a different compression level for JPG?
Ben
Re: How to resize *.png picture with auto-adjustment?
Posted: 2014-03-17T04:34:48-07:00
by snibgo
Specify the compression you want with "-quality". See
http://www.imagemagick.org/script/comma ... hp#quality .
If the input is jpeg, the default output quality is the same as the input. If the input isn't jpeg, the current default quality seems to be 92. (I think it used to be 85. Perhaps it depends on the jpeg library. If you want a specific setting, don't rely on the default remaining unchanged.)
Quality 100 for jpeg is the least lossy, but still lossy.
Re: How to resize *.png picture with auto-adjustment?
Posted: 2014-03-18T08:23:59-07:00
by glennrp
snibgo wrote: If the input isn't jpeg, the current default quality seems to be 92. (I think it used to be 85. Perhaps it depends on the jpeg library. If you want a specific setting, don't rely on the default remaining unchanged.)
92 is ImageMagick's default in coders/jpeg.c. Digital cameras typically use 90-95.