It's been decades since I've worked with PHP, but one thing I'd check is if the relevant image pointers have transparency enabled.
For example, if you load the image in using GD, you need to run
imagealphablending() to enable blending and
imagesavealpha() to enable outputting the alpha channel using something like
imagepng().