Batch-converting images

I had a wad of images that I needed to resize from 300dpi and high-resolution jpg to 4.5×6 (or 6×4.5) low resolution at 72 dpi.

First, I installed ImageMagick:
sudo aptitude install imagemagick

Then I opened GIMP and determined the pixel width and height of one image. (Image -> Canvas Size). In my case, it was 3264×2448.

Next, I resized the image to the size I wanted. That turned out to be 432×324.

In other words, I wanted my new images to be 0.132352941 of the original image. A quick test told me I was on the right track:

convert P4250049.JPG -resize 13.2352941% test.jpg

The first time I did this I forgot the % sign and got a 13×10 pixel image – not exactly what I wanted.

So, on to batch-converting everything in a directory:

mkdir ./resized
for i in *.JPG; do
echo $i
convert $i -resize 13.235941% -quality 20 ./resized/$i

And all my resized images were in the resized directory below the image directory. (Did I mention I wanted to reduce the quality so my images would be smaller too? Yep, that’s what the -quality line does.)

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: