Not a bug Avatars: PNG transparency not always preserved

Steffen

Well-known member
Affected version
2.0.2
I've stumbled upon a PNG avatar whose transparency is not preserved by XenForo. Most other avatars don't have this problem.

I've attached an avatar whose transparency is preserved (good.png) and an avatar whose transparency is not preserved. The following code essentially does the same thing as XF\Image\Gd and can be used to reproduce the problem.
PHP:
<?php
$image = imagecreatefrompng($argv[1]);
imagealphablending($image, false);
imagesavealpha($image, true);
imagepng($image, $argv[2]);

Bash:
php image.php bad.png out.png

If I remove the imagealphablending and imagesavealpha calls then "bad.png" works fine but "good.png" fails. Maybe these calls should happen depending on some property of the input file. But I have not found out what property that is.

Maybe the issue exists on files where identify -verbose <file.png> reports "Type: TrueColorAlpha" instead of "Type: PaletteAlpha".
 

Attachments

Just to confirm, you've stumbled across a single avatar image that loses its transparency? I can reproduce what you're reporting, but only with this single image. It's not something I recall seeing in the past so if anything, I think the avatar is at fault (or the underlying libraries) rather than anything we have any impact over. FWIW, Gravatar and other image upload type scripts seem to handle it in the same way, so I really don't think it's something we should be forensically analysing or attempting to make changes which could impact images which right now otherwise upload correctly.
 
I've checked 10 other avatars with transparency and they don't share this problem. I think this issue is not relevant enough, feel free to close it.
 
Top Bottom