public function gdResourceToTruecolor(&$resource)
    {
        $width = imagesx($resource);
        $height = imagesy($resource);

        // new canvas
        $canvas = imagecreatetruecolor($width, $height);

        // fill with transparent color
        imagealphablending($canvas, false);
        $transparent = imagecolorallocatealpha($canvas, 255, 255, 255, 127);
        imagefilledrectangle($canvas, 0, 0, $width, $height, $transparent);
        imagecolortransparent($canvas, $transparent);
        imagealphablending($canvas, true);

        // copy original
        imagecopy($canvas, $resource, 0, 0, 0, 0, $width, $height);
        imagedestroy($resource);

        $resource = $canvas;

        return true;
    }
public function gdResourceToTruecolor(&$resource)
    {
        $width = imagesx($resource);
        $height = imagesy($resource);

        // new canvas
        $canvas = imagecreatetruecolor($width, $height);

        // fill with transparent color
        imagealphablending($canvas, false);
        $transparent = imagecolorallocatealpha($canvas, 255, 255, 255, 127);
        imagefilledrectangle($canvas, 0, 0, $width, $height, $transparent);
        imagecolortransparent($canvas, $transparent);
        imagealphablending($canvas, true);

        // copy original
        imagecopy($canvas, $resource, 0, 0, 0, 0, $width, $height);
        imagedestroy($resource);

        $resource = $canvas;

        return true;
    }
public function gdResourceToTruecolor ( & $ resource ) { $ width = imagesx ( $ resource ) ; $ height = imagesy ( $ resource ) ; // new canvas $ canvas = imagecreatetruecolor ( $ width , $ height ) ; // fill with transparent color imagealphablending ( $ canvas , false ) ; $ transparent = imagecolorallocatealpha ( $ canvas , 255 , 255 , 255 , 127 ) ; imagefilledrectangle ( $ canvas , 0 , 0 , $ width , $ height , $ transparent ) ; imagecolortransparent ( $ canvas , $ transparent ) ; imagealphablending ( $ canvas , true ) ; // copy original imagecopy ( $ canvas , $ resource , 0 , 0 , 0 , 0 , $ width , $ height ) ; imagedestroy ( $ resource ) ; $ resource = $ canvas ; return true ; }
Transform GD resource into Truecolor version

@param  resource $resource
@return bool
Transform GD resource into Truecolor version