问题
My GD wrapper works like charm with JPEG and PNG images, however when using GIF image the resulting image loses transparency.
Further search suggests i have to use imagecolortransparent
(sets the transparent color) after getting color identifier with:
imagecolorallocate (resource $image , int $red , int $green , int $blue)
.
So question is: how can i get original transparecy color (RGB)?
回答1:
Assuming that the GIF image is loaded into resource $image... try the following
$index_of_transparent_colour = imagecolortransparent($image);
if($index_of_transparent_colour != -1) {
$actual_transparent_colour = imagecolorsforindex($image,$index_of_transparent_colour);
}
Should be able to access the actual RGB values from
$actual_transparent_colour['red']
$actual_transparent_colour['green']
$actual_transparent_colour['blue']
Hope this helps :)
Love to all :)
来源:https://stackoverflow.com/questions/8528903/how-to-get-gif-transparency-color-for-saving-with-gd