Tool Chain: ImageMagic Commands Exposed

The generator uses the ImageMagick tool suite to clip and combine images. In the framework we only need this functionality when particular images change, new images are added (e.g. for a theme), and combined images have to be regenerated, which occurs rather infrequently. (If you never clipped or combined an image in your qooxdoo projects, don’t worry).

So far the corresponding ImageMagick command invocations were hard-wired in the generator. But as ImageMagick changes the syntax of command-line arguments of their tools, like positions, between releases (and sometimes even their semantics!), it was hard to come up with a generator implementation that would work across some IM versions. To amend this, the IM commands are now part of the configuration of the image jobs, so everybody can tweak them to suit their local IM installation (config keys combine-images/montage-cmd and split-images/convert-cmd).

The configuration values are template strings that have named placeholders (like ‘%(infile)s‘ or ‘%(orientation)s‘). Whenever you shuffle the command line, these should be kept intact so the generator can expand them at runtime with dynamic values. For our IM installations (v6.5 and v6.6), these command lines currently work:

"convert %(infile)s -crop %(xoff)sx%(yoff)s+%(xorig)s+%(yorig)s +repage %(outfile)s"
"montage @%(tempfile)s -geometry +0+0 -gravity NorthWest -tile %(orientation)s -background None %(combinedfile)s"

2 thoughts on “Tool Chain: ImageMagic Commands Exposed

  1. Why not use imagemagick bindings for python (Or even graphicsmagick, which also has python bindings, which is faster than imagemagick in most situations)?

  2. @Leandro Good point, I will look into that. Though using command-line interfaces from Python is usually not the worst option. But this one might be different …

Comments are closed.