How can I resize a batch of images using Automator, so that all images will have a fixed height, e.g. I want to resize all images to be 60px high while width can be anything.
2 Answers
You can also batch-resize images from Preview:
Or install ImageMagick with brew install imagemagick
or sudo port install imagemagick
and use something like this:
for f in *.png; do convert $f -filter lanczos2 -resize x60 -quality 93 ${f%png}jpg; done
More examples:
# modify images in place and make images larger than 1280x1280 pixels smaller
mogrify -filter lanczos2 -resize '1280x1280>' *.png
# save thumbnails to ~/Desktop and make images wider than 500 pixels smaller
mogrify -filter lanczos2 -thumbnail 'x500>' -format jpg -quality 93 -path ~/Desktop/ *.png
# make images smaller or larger and crop them so that they are exactly 200x200 pixels
-resize 200x200^ -extent 200x200 -gravity center
# use a white instead of a black background
convert transparent-bg.png -flatten white-bg.jpg
The default filter for downscaling images is Triangle
, which often makes images look too blurry without additional sharpening in my opinion. Triangle
is similar to the resizing methods used by Automator and sips
. I usually use Lanczos2
(2-lobe Lanczos), which makes images less sharp than Lanczos
(Lanczos3
or 3-lobe Lanczos). Lanczos2
is almost identical to Catrom
, and it is also similar to the bicubic option in Photoshop.
A comparison of different resizing options: http://lri.me/upload/imagemagick-osx-resizing/index.html
-
Now, a bash two-liner more difficult than getting imagemagick set up and having it perform the desired action? Hard to believe ;-)– Daniel Beck ♦May 13, 2011 at 8:20
-
Wow, I've been on OS X for over a decade now and I didn't know that Preview was capable of batch editing! That's totally awesome as it's available on every Mac and dead simple to use. Even batch conversion of file formats is possible and works analogous to resizing: goo.gl/wQ1osW Jan 25, 2014 at 17:55
Use (install) the Action "Save for Web" available in http://junecloud.com/software/mac/junecloud-automator-actions.html.
Worked for me :).
You can specify a maximum with and Height for the image.