Resizing Digital Pictures Made Easy

One might think it’s not that much of a task to resize a bunch of files in one directory so a certain dimention. Say you want to have all jpg images in your directory have width 1024 with aspect ratio maintained. For one image using GIMP actually this is easy. Just open it, go to image > scale image and type “1024” for width. That’s it. Knowing of GIMP’s batch mode feature I though: Well, now let’s just do this very same thing in batch mode for multiple files. Googling I found this passage Adrian Likins GIMP Batch How-To:

Batch mode is slow. Its not really a practical replacement for tools like ImageMagick or NetPBM when it comes to large scale image conversions or similar. At least not without writing some very clever scripts.
The problem with this approach is that gimp/script-fu has no built in procedures to iiterate though a list of images. So you cant easily tell gimp to load up *.jpg and run predator.scm on them, at least not without it taking a _long_ time.

There’s the solution, I thought. So I installed ImageMagick for Windows and made myself ready to run a Windows batch for loop on the files. After double checking against ImageMagick’s delivered help for convert I knew the syntax:

convert  -resize 1024

So far so good. But now comes the Windows batch bit. Even though fairly powerfull even compared with bash or other mighty script languages on Linux I couldn’t figure out how to run more than one command per iteration step. This is what I came around to, which does what intended, but without a pretty notice to the user that could have been done with adding something like ; @echo %i

for /f %i in ('dir /b *.jpg') do convert %i -resize 50% %i

Note that I chose to halve the pics rather than to hard-set the width so I don’t risk upright pictures to become bigger in file size than the original. There you go!

Update: I finally came around to do it with Linux. Here is the Bash equivalent to the above (plus an additional nice notification which is easy with Bash):

for i in *.jpg; do echo "converting \"$i\"..."; convert "$i" -resize 50% "$i"; done


  1. Saturday, 18th Jun 2011 at 13:32

    One important thing is that if you find yourself searching for a education loan you may find that you will want a co-signer. There are many conditions where this is true because you might find that you do not have a past credit history so the loan provider will require you have someone cosign the financial loan for you. Thanks for your post.

  2. sysblog said,

    Wednesday, 26th Mar 2008 at 10:28

    Ta a bunch, Marc, for dropping a comment and your hint about using AND to use multiple commands within windows for foop!

    I edited your text so to show the code nicely.

  3. Marc said,

    Wednesday, 26th Mar 2008 at 07:11

    Thanks for the indo.

    In windows you’d be better with the standard “for” statement, and you use && to separate commands, thus the following should do what you were after:

    for %i in (*.jpg) do @echo Converting %i && @convert %i -resize 50% %i
  4. Andy said,

    Wednesday, 19th Dec 2007 at 19:36

    Oh, and did not know about it. Thanks for the information …

  5. Sunday, 30th Sep 2007 at 13:08

    […] to convert pixel files (png) to vector graphic (svg) on Linux In another post I wrote about the small tool convert as part of imagemagick. With convert it is possible to, […]

  6. grzzap said,

    Sunday, 30th Sep 2007 at 12:21

    nice site!

  7. Monday, 20th Aug 2007 at 11:42

    […] that the performance of GIMP scripting in Windows was less than ideal and came across another WordPress blog that mentioned ImageMagick, which is free and allows image manipulation from the command […]

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: