Patch: Avatar PNG Transparency (Bugs)

by beornlake, Friday, June 20, 2014, 13:59 (3570 days ago) @ Auge

I'm new to the image creation process. That said, let's analyse the code (a bit). The description for the function imagesavealpha says "You have to unset alphablending, to use it.". Maybe it's a good idea to do that explicitely to ensure the use of the original image data.

Indeed, that's correct. I had left the imagealphablending() call out because it defaults to being off, but you're probably right that it's a good idea to explicitly turn it off anyway:

if(empty($error)) {
  imagealphablending($new_image, false);
  imagesavealpha($new_image, true);
  $transparency_fill = imagecolorallocatealpha($new_image, 0, 0, 0, 127);
  imagefill($new_image, 0, 0, $transparency_fill);
}

Complete thread:

 RSS Feed of thread