Upgrade Breakage

Last summer I implemented watermarking for all hotlinked images.  But while checking referrer logs today I came across some images that weren’t getting watermarked.  This puzzled me at first, as all the logs clearly showed that the file was being properly redirected and they were picking up the watermarked version.  Examining the cache showed that everything since late December wasn’t getting the watermark added (the cache image was the same as the original).

Looking at the watermarking script and the fact that it used the composite command from ImageMagick reminded me that Dreamhost had just upgraded ImageMagick.  They’d long been running on a very downlevel version and upgraded at the end of December to v6.2.4 (which is still a bit odd, given that the current release is 6.3.1).  Thinking that perhaps something in the command line had changed from v5 to v6, I tried manually running the command.  Even with debugging and verbose options on, it showed no errors and the invocation matched the example in the documentation.  It just wasn’t adding the image overlay.

So I took a further look at the documentation and they had an example of using commands to dynamically generate the text (with associated background changes to help differentiate it).  I created a small script that used parameters for the filename and replaced the composite command in the watermarking script with my script.

#!/bin/bash
convert -size 250×35 xc:none -gravity center \
    -stroke black -strokewidth 2 -annotate 0 ‘Hotlinked from aubreyturner.org!’ \
    -channel RGBA -blur 0x3 \
    -stroke none -fill white   -annotate 0 ‘Hotlinked from aubreyturner.org!’ \
    +size $1 +swap \
    -gravity south -geometry +0-2 -composite $2

I still don’t know what broke in composite with the upgrade, but at least this works and looks better than my original.

Hotlinkers will get the image with the text added at the bottom in the center, like this:
Flight deck image

Comments are closed.