I'm working with the PHP GB library to manipulate images. One of the thing I noticed doesn't come with the GB library is the ability to flip images either vertically or horizontally. So I went about building my own function for it. This is what I got:
function flipImage($image) {
$width = imagesx($image);
$height = imagesy($image);
$out = imagecreatetruecolor($width, $height);
for($i = 0; $i < $width; $i++) {
// Copy the image strip going left to right
imagecopy($out, $image, $width - $i, 0, $i, 0, 1,开发者_如何学Python $height);
}
//$out should now hold our flipped image
return $out;
}
It works as I expected it to, but for some reason the returned image ($out
) has a black background instead of a transparent one.
Is there any way to get the returned image to have a transparent background like the source image was?
http://www.akemapa.com/2008/07/10/php-gd-resize-transparent-image-png-gif/
You need to allocate transparency to a specific value.
精彩评论