I have a script that takes small images (450x300) and creates a square thumbnail for each one via a resize and a crop. Traditionally, I've been using a for-loop in a /bin/sh script:
Code: Select all
$ time for i in *.jpg ; do convert -gravity northwest $i -resize 45x45 -crop 30x30+0+0 thumbs/$i ; done
real 2m26.706s
user 1m39.739s
sys 1m16.515s
This is ImageMagick 6.3.0 (11/05/06 Q16) under Cygwin under Windows XP, and I would like to improve the performance and efficiency of this batch process. After reading Anthony's excellent notes at
http://www.cit.gu.edu.au/~anthony/graphics/imagick6/, I discovered I could do something like this:
Code: Select all
$ time convert -gravity northwest '*.jpg[45x45]' -crop 30x30+0+0 thumbs/
real 1m7.884s
user 1m0.451s
sys 0m6.577s
In both examples, a total of 1222 JPEGs were processed. By avoiding the 1221 extraneous forks, I can cut the running time by more than half. The problem is that the output filenames are not in the format I need. I do not need %d, %o or %x... I simply want the output filename to be the same as the input filename, and I cannot find a way to do that. IM appears to insist on using a counter variable! Is there a way to disable this, and simply preserve the filename as-is?
The output JPEGs are exactly as I like them... it's ironic that a file naming issue is the only remaining obstacle. So close, yet so far away...