CodeIgniter Forums
Manipulating transparent images causes "blackness" - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Manipulating transparent images causes "blackness" (/showthread.php?tid=17770)



Manipulating transparent images causes "blackness" - El Forum - 04-15-2009

[eluser]crispyslice[/eluser]
When the image manipulation class is used to resize images with transparency, any transparency in the image is replaced with black. I found a fix on these forums which basically consists of adding this to the image manipulation class:
Code:
$transparent_index = imagecolortransparent($src_img);
        if ($transparent_index >= 0) {
            imagepalettecopy($src_img, $dst_img);
            imagefill($dst_img, 0, 0, $transparent_index);
            imagecolortransparent($dst_img, $transparent_index);
            imagetruecolortopalette($dst_img, true, 256);
        }

I think it would be beneficial to CodeIgniter if this was fixed in the official release, and didn't require a hack to get it working properly.

This issue is present in 1.7.1, and I included an example of a resized image with transparency for reference.