I am trying to generate an image out of two images. I have a background image, and then an object image. The object image is drawn onto the background image. The object image's background should be transparent so that the "background image" can show through after the drawing.
Is there a way to do this with PNG's built-in transparency, rather than using the set transparency function?
imagecopy() with PNG alpha transparency?
Moderators: onion2k, General Moderators
- Josh1billion
- Forum Contributor
- Posts: 316
- Joined: Tue Sep 11, 2007 3:25 pm
- Josh1billion
- Forum Contributor
- Posts: 316
- Joined: Tue Sep 11, 2007 3:25 pm
Re: imagecopy() with PNG alpha transparency?
Nevermind, got it! A good hour or two of frustration is finally over!
Solution:
I changed my imagecopymerge() function to imagecopy() instead (and removed the last argument which isn't used in imagecopy()).
Solution:
I changed my imagecopymerge() function to imagecopy() instead (and removed the last argument which isn't used in imagecopy()).
Re: imagecopy() with PNG alpha transparency?
It can be done with imagecopy() too.. you just need to make sure the imagesavealpha() and imagealphablending() values are correct for both images.
- Josh1billion
- Forum Contributor
- Posts: 316
- Joined: Tue Sep 11, 2007 3:25 pm
Re: imagecopy() with PNG alpha transparency?
What I meant was that I was originally trying to use imagecopymerge(), and the solution was to change that to imagecopy() instead.
Re: imagecopy() with PNG alpha transparency?
hi!
i m facing the same Problem i want transparent image of some width n height and text on that image...but when i m using imageSaveAlpha($image, true);
ImageAlphaBlending($image, false); its not working...
<?php
Header('Content-type: image/png');
//$size = 300;
//$Img=imagecreatetruecolor(100,30);
$Img = imagecreate(110,30);
$Gray = imagecolorallocatealpha($Img, 0, 0, 255, 10);
$text = 'Testing..';
imageFilledRectangle($Img,0,0,100,100,$Gray);
imagecolortransparent($Img,$Gray);
$font = 'Shelley_AllegroScript.ttf';
imagettftext($Img, 20, 0, 10, 20, $Gray, $font, $text);
//imagestring($Img,4,0,0,$text,$Gold);
//imagecolortransparent($Img,$Gray);
imagepng($Img);
ImageDestroy($Img);
?>
then i m getting diminished text....
i m facing the same Problem i want transparent image of some width n height and text on that image...but when i m using imageSaveAlpha($image, true);
ImageAlphaBlending($image, false); its not working...
<?php
Header('Content-type: image/png');
//$size = 300;
//$Img=imagecreatetruecolor(100,30);
$Img = imagecreate(110,30);
$Gray = imagecolorallocatealpha($Img, 0, 0, 255, 10);
$text = 'Testing..';
imageFilledRectangle($Img,0,0,100,100,$Gray);
imagecolortransparent($Img,$Gray);
$font = 'Shelley_AllegroScript.ttf';
imagettftext($Img, 20, 0, 10, 20, $Gray, $font, $text);
//imagestring($Img,4,0,0,$text,$Gold);
//imagecolortransparent($Img,$Gray);
imagepng($Img);
ImageDestroy($Img);
?>
then i m getting diminished text....