PHP GD - Transparent areas turn black

I am trying to make a very simple ISO engine in PHP, my attempts to display in the right place, order, etc. succeed, but images created for some reason are black, where they must be transparent. PNG files have a transparency channel, and I use the following test code: http://pastebin.com/TXk4LkJ8 The code is just a draft.

Files are just 3 faces of a block with sizes: top - 44x22; sides: 23x34

Thanks for your help, and I hope this question is clear enough.

Edit: here is the problem: http://dl.dropbox.com/u/10530011/obrazki/isofail.png

Edit: [ SOLVED ] For some reason, I had to save GIF images in order for them to work. Thank you for your help.

+6
source share
2 answers

You should call these two functions before , saving the png image, imagealphablending () and imagesavealpha () :

imagealphablending( $image, false ); imagesavealpha( $image, true ); 
+12
source

This answer suggests two things:

  • imagealphablending must be set to false to preserve alpha channels
  • You must set the transparent color (in this case black) to transparent:
 $black = imagecolorallocate($image, 0, 0, 0); imagecolortransparent($image, $black); 

Does it help?

+3
source

Source: https://habr.com/ru/post/887454/


All Articles