Jump to content

[SOLVED] PHP, GD & Image Transparency


seanmt

Recommended Posts

Hi,

 

I'm having a bit of trouble with PHP & GD. I want the background of the image to be transparent but when I create a new image using...

 

$im = imagecreatefrompng("backgrounds/bg7.png");

 

The resulting image just ends up with horrible black colour around the edge of it (as seen in the attached image). The original image can be seen here.

 

All help will be much appreciated.

 

 

[attachment deleted by admin]

Link to comment
https://forums.phpfreaks.com/topic/175653-solved-php-gd-image-transparency/
Share on other sites

Ah nevermind. I tried using imagesavealpha again but this time I used it correctly. Doh.

 

$im = imagecreatefrompng("backgrounds/bg7.png");

//
// misc operations on the image...
//

//JUST ADDED THESE 2 LINES TO MY CODE AND IT ALL WORKS FINE NOW
imagealphablending($im, false);
imagesavealpha($im, true);

imagepng($im);

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.