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
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

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.