Imagick compositing and opacity

I’m using the Imagick class to composite one image onto another:


$overlay = new Imagick($overlay);
$img->compositeImage($overlay, Imagick::COMPOSITE_SRCOVER, $x, $y);

Assume $overlay and $img are valid Imagick objects, and $x and $y are both set.

This works fine and gives me the following image:

(excuse the bad quality, it’s to keep the filesize down).

Now, if I try to apply opacity to the overlay, it renders the transparent background as a checkerboard:


$overlay = new Imagick($overlay);
$overlay->setImageOpacity(.5);
$img->compositeImage($overlay, Imagick::COMPOSITE_SRCOVER, $x, $y);

I’ve tried all sorts of COMPOSITE_* constants and other ways of getting making the overlay image semi-transparent, but without luck.

Who can shed some light?