Blog of Raivo Laanemets

Stories about web development, freelancing and personal computers.

ImageMagick resizes output image with bad geometry argument value


ImageMagick is a command line image manipulation library. I have used it in many projects for processing images. Recently I hit a strange bug in one of the projects where the command for adding a watermark resized the output image into the size of 10x8 pixels.

The issue occurred only in the production environment running with the ImageMagick version 6.7.7-10 but not on the development environment running with the version 6.8.6-10. The command for adding the watermark was the following:

composite -dissolve 70 -quality 100 -gravity east \
    -geometry +10 watermark.png 1.jpg 1-watermarked.jpg

Running with the -verbose argument on 6.7.7-10 shows that the output image is being resized:

watermark.png PNG 51x200 51x200+0+0 8-bit DirectClass 6.37KB 0.000u 0:00.000
1.jpg JPEG 3264x2448 3264x2448+0+0 8-bit DirectClass 2.723MB 0.210u 0:00.220
1.jpg=>1-watermarked.jpg JPEG 3264x2448=>10x8 10x8+0+0 8-bit DirectClass 0.620u 0:00.309

The reason is the (invalid) value +10 to the geometry parameter. Using +10+0 will make it work as expected. +10 however works on 6.8.6-10. The changelog does not contain any clue between 6.7.7-10 and 6.8.6-10 that the geometry parameter parsing was changed and the bug forum does not seem to contain anything about it.

Hopefully this helps to debug resize issues for someone else too.


Comments

No comments have been added so far.

Email is not displayed anywhere.
URLs (max 3) starting with http:// or https:// can be used. Use @Name to mention someone.