Acoon Posted August 12, 2011 Share Posted August 12, 2011 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 instead of this: I'm not changing the image, just passing it through. Br, Acoon Quote Link to comment https://forums.phpfreaks.com/topic/244597-php-gd-and-transparent-images/ Share on other sites More sharing options...
WebStyles Posted August 12, 2011 Share Posted August 12, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/244597-php-gd-and-transparent-images/#findComment-1256331 Share on other sites More sharing options...
Acoon Posted August 12, 2011 Author Share Posted August 12, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/244597-php-gd-and-transparent-images/#findComment-1256358 Share on other sites More sharing options...
shlumph Posted August 12, 2011 Share Posted August 12, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/244597-php-gd-and-transparent-images/#findComment-1256446 Share on other sites More sharing options...
Acoon Posted August 12, 2011 Author Share Posted August 12, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/244597-php-gd-and-transparent-images/#findComment-1256510 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.