Scripted Multiple Resizes With ImageMagick
The problem: A friend had taken a screen capture and was having difficulties getting it to display nicely in WordPress.
An interesting challenge I thought to myself. I know I can use all sorts of funky resize filters with ImageMagick, but which one would work best? A few clumsy minutes later, I had an answer, but that in turn raised another. Just editing the command history is fine and dandy, but there must be a better, faster, more efficient way!
Surely I can script something that will generate all the variants in a single go???
And there surely is:
|
This (effectively) one liner shell script:
- Loops over the various filters that recent versions (v6.3+ ??) of ImageMagick can process.
- Displays the current filter being used to the console. The equivalent of seeing an hour-glass.
- Applies that filter to the resize operation.
- Puts in a 20 point sized watermark into the image. The watermark text being the filter used. Because I could.

- Writes this new image out into a subdirectory (converted) with a new filename being the filter.
It is then extremely easy to use an image viewer and rapidly page between the new versions.
Once a filter to use has been chosen? Just run the convert command with that single filter only, and minus the -draw stuff.
convert -filter Hermite -resize 563x367 custom-advanced-a-and-b.png custom-advanced-a-and-b.SMALL.png
Easy! 



