Resizing a png tranparent image.
| From: | Vincent M. | Date: | Sat, 28 Dec 2002 21:09:55 +0000 |
| Subject: | Resizing a png tranparent image. | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-129532@lists.php.net to get a copy of this message | ||
Hello,
I am trying to resize a png file, my autograph ;-)
Good result thanks to gimp:
http://boxfly.free.fr/test/test1.jpg
Bad result with php:
http://boxfly.free.fr/test/test2.jpg
This is my PHP code to resize the autograph:
$newAuto = imagecreatetruecolor( $widthImgAu, $heightImgAu) ;
imagecolortransparent($newAuto,imagecolorat($newAuto,0,0)) ;
$imgAuto = ImageCreateFromPNG($img_auto);
imagecopyresized($newAuto, $imgAuto, 0, 0, 0, 0, $widthImgAu, $heightImgAu, $imageInfoAu[0], $imageInfoAu[1]) ;
ImagePNG($newAuto,"new_auto.png");
So I tried:
imagecopyresampled($newAuto, $imgAuto, 0, 0, 0, 0, $widthImgAu, $heightImgAu, $imageInfoAu[0], $imageInfoAu[1]) ;
Instead of imagecopyresized...
To copy the autograph inside the photo I do:
$newImg = ImageCreateFromJPEG($img_des);
ImageAlphaBlending($newImg, true);
ImageCopy($newImg, $newAuto, $posX, $posY, 0, 0, $widthImgAu, $heightImgAu);
But with no sucess
If I do not resize the png autograph and copy it directly inside the photo, that's perfect, as a result the problem is the resizing...
What do I have to do to resize a png image without loosing transparency ?
Thanks.