Page 1 of 1

Auto adjust photos into preset boundaries

Posted: 2010-05-06T19:06:00-07:00
by jarhar
I create random sized image files (usually from screen and document clippings) that need to converted so that they are no larger than 400x220. Is there a way that ImageMagick can automatically adjust the sizes of the files so that they will fit into the 400x220 space? I don't want them cropped, just the whole things sized down to fit within 400x220.

Thanks.

Re: Auto adjust photos into preset boundaries

Posted: 2010-05-06T19:26:42-07:00
by fmw42
-resize "400x220!" will force the image to exactly that size, but you may get distortion as it won't preserve aspect ratio

-resize 400x220 will resize the larger dimension of the image to fit one or the other parameter as appropriate and the other image dimension will be smaller than the other argument

see http://www.imagemagick.org/script/comma ... p#geometry

Re: Auto adjust photos into preset boundaries

Posted: 2010-05-06T19:58:41-07:00
by jarhar
Awesome, thanks, the second option is just what I need. What would be the easiest way for me to implement ImageMagick for doing this? Could I put all the images needing this done into a folder and run ... -resize 400x220 *.* and have it do all in the folder at once? Or what would be the easiest (fastest) way? For one at a time and for groups?

Re: Auto adjust photos into preset boundaries

Posted: 2010-05-06T21:13:57-07:00
by fmw42
I would create a second empty directory for safety in case something goes wrong and write the results using mogrify to that directory. It will do all files in a directory. For example, create directory test1 with your images and directory test2 that is empty.

cd /fullpathto/test1
mogrify -path /fullpathto/test2 -format jpg -resize WidthxHeight *.*

will convert any filetype to jpg while reducing the images

or

mogrify -path /fullpathto/test2 -format jpg -resize WidthxHeight *.png

will convert only png to jpg while reducing the images


see mogrify at http://www.imagemagick.org/Usage/basics/#mogrify

Re: Auto adjust photos into preset boundaries

Posted: 2010-05-06T21:29:54-07:00
by jarhar
Great solution. I'm looking forward to getting it set up (probably a little script and a shortcut to the script) and using it. Thanks a lot for your help.