note 80830 modified in function.imagecopy by felipe
| From: | felipe@php.net | Date: | Mon, 04 Feb 2008 20:22:43 +0000 |
| Subject: | note 80830 modified in function.imagecopy by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-135767@lists.php.net to get a copy of this message | ||
I had the same problem as Jeff, but his solution didn't work for me. I made this script, and it
seems to work:
<?php
$img = imagecreatefromgif('in.gif');
$w = imagesx($img);
$h = imagesy($img);
$trans = imagecolortransparent($img);
if($trans >= 0) {
$rgb = imagecolorsforindex($img, $trans);
$oldimg = $img;
$img = imagecreatetruecolor($w,$h);
$color =
imagecolorallocate($img,$rgb['red'],$rgb['green'],$rgb['blue']);
imagefilledrectangle($img,0,0,$w,$h,$color);
imagecopy($img,$oldimg,0,0,0,0,$w,$h);
}
imagegif($img,'out.gif');
?>
--was--
I had the same problem as Jeff, but his solution didn't work for me. I made this script, and it
seems to work:
<?php
$img = imagecreatefromgif('in.gif');
$w = imagesx($img);
$h = imagesy($img);
$trans = imagecolortransparent($img);
if($trans!==FALSE) {
$rgb = imagecolorsforindex($img, $trans);
$oldimg = $img;
$img = imagecreatetruecolor($w,$h);
$color =
imagecolorallocate($img,$rgb['red'],$rgb['green'],$rgb['blue']);
imagefilledrectangle($img,0,0,$w,$h,$color);
imagecopy($img,$oldimg,0,0,0,0,$w,$h);
}
imagegif($img,'out.gif');
?>
http://php.net/manual/en/function.imagecopy.php