Forum Moderators: coopster
if ( ($this->mime == 'image/gif') || ($this->mime == 'image/png') ) {
$trnprt_indx = imagecolortransparent($this->src);
// If we have a specific transparent color
if ($trnprt_indx >= 0) {
echo 'tosspot7';// this works for gifs and png 8
// Get the original image's transparent color's RGB values
$trnprt_color = imagecolorsforindex($this->src, $trnprt_indx);
// Allocate the same color in the new image resource
$trnprt_indx = imagecolorallocate($this->tmp, $trnprt_color['red'], $trnprt_color['green'], $trnprt_color['blue']);
// Completely fill the background of the new image with allocated color.
imagefill($this->tmp, 0, 0, $trnprt_indx);
// Set the background color for new image to transparent
imagecolortransparent($this->tmp, $trnprt_indx);
}
// Always make a transparent background color for PNGs that don't have one allocated already
elseif ($this->mime == 'image/png') {
echo 'tosspot3'; // PNG32 comes here bit fails
// Turn off transparency blending (temporarily)
imagealphablending($this->tmp, false);
// Create a new transparent color for image
// $color = imagecolorallocatealpha($this->tmp, 0, 0, 0, 127);
$color = imagecolorallocatealpha($this->tmp, 255, 255, 255, 127);
// Completely fill the background of the new image with allocated color.
imagefill($this->tmp, 0, 0, $color);
// Restore transparency blending
imagesavealpha($this->tmp, true);
}
}