Preserve PNG-32 Transparency using sfImageTransformPlugin

If you merge a PNG-32 (PNG format with an aplha channel) with another image, the transparent part of the original image will render with a solid black colour. The fix for this is quite simple.

$bg = new sfImage('main_image.jpg');
$bg = new sfImage('blank_frame.png');   // has alpha channel
$bg->transparency('#000000');             // preserve alpha channel
$bg->overlay($img, array(10,10));

The resulting image will retain the alpha channel transparency.

One thought on “Preserve PNG-32 Transparency using sfImageTransformPlugin

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>