Jump to content

PHP GD and transparent images


Acoon

Recommended Posts

Hi all,

 

Can anyone tell me why this fails and screw up the image?

 

<?php
$url = "http://eu.battle.net/wow/static/images/guild/tabards/emblem_100.png";
$im=imagecreatefrompng($url);
header('Content-Type: image/png');
imagepng($im);
imagedestroy($im);
?>

 

Gives this

gd.php

 

instead of this:

emblem_100.png

 

I'm not changing the image, just passing it through.

 

Br,

Acoon

Link to comment
https://forums.phpfreaks.com/topic/244597-php-gd-and-transparent-images/
Share on other sites

I just tested and got the same result, but then I opened photoshop and created a second png (from your original) and saved as PNG-8 (instead of (PNG-24) and it worked.

Yeah,

but the problem is that i can't download and keep all the graphics up to date. I rather pick it from the remote location.

Is there any way to solve this?

 

Br,

Acoon

You'll probably need to use alphablending, since you're dealing with transparency:

 

$url = "http://eu.battle.net/wow/static/images/guild/tabards/emblem_100.png";
$im=imagecreatefrompng($url);
imagealphablending($im, true);
imagesavealpha($im, true);
header('Content-Type: image/png');
imagepng($im);
imagedestroy($im);

 

http://www.php.net/manual/en/function.imagealphablending.php

http://www.php.net/manual/en/function.imagesavealpha.php

 

You'll probably need to use alphablending, since you're dealing with transparency:

 

$url = "http://eu.battle.net/wow/static/images/guild/tabards/emblem_100.png";
$im=imagecreatefrompng($url);
imagealphablending($im, true);
imagesavealpha($im, true);
header('Content-Type: image/png');
imagepng($im);
imagedestroy($im);

 

http://www.php.net/manual/en/function.imagealphablending.php

http://www.php.net/manual/en/function.imagesavealpha.php

 

Hi, thanks for the effort.

But i already tried this also with no luck.

 

Any other ideas?

 

Br,

Acoon

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.