Friday, February 4, 2011

Preserve transparency when dynamically resize PNG images with joomslide

Here is a quick hack on joomslide to fix issue when transparent background PNG images are resized and a black background is used instead.

in plugins/content/joomslide.php find the line
if ($this->pluginRegistry->doCrop) $this->CalculateCropArea();
Append the following after the line above:
imagealphablending($dst_img, false);
imagesavealpha($dst_img,true);
imagefilledrectangle($dst_img, 0, 0, $this->pluginRegistry->thumbWidth, $this->pluginRegistry->thumbHeight, IMG_COLOR_TRANSPARENT);
Viola!

No comments:

Post a Comment