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
How to resize *.png picture with auto-adjustment?
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: How to resize *.png picture with auto-adjustment?
Code: Select all
convert picture.png -resize x800 picture.png
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
See:
http://www.imagemagick.org/script/comma ... php#resize
http://www.imagemagick.org/script/comma ... p#geometry
snibgo's IM pages: im.snibgo.com
Re: How to resize *.png picture with auto-adjustment?
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
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
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: How to resize *.png picture with auto-adjustment?
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.
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.
snibgo's IM pages: im.snibgo.com
Re: How to resize *.png picture with auto-adjustment?
92 is ImageMagick's default in coders/jpeg.c. Digital cameras typically use 90-95.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.)