png image loses transparency

Shane Bishop <[email protected]> Fri, 8 May 2020 10:31:00 -0600
Newsgroups gmane.comp.video.graphicsmagick.help
Message-ID <CAOSZYLg4ZNdRf0--AVbAhZhWrfKYmagV9jY1p85DW1XYuddbeg@mail.gmail.com>
I'm using the gmagick module for PHP, running into an issue with an 8-bit
PNG (attached) where simply doing this causes the PNG to lose it's
transparency (image ends up with a black background):

$url = 'https://yamm.co/wp-content/uploads/2020/04/iPhone-Yamm.png';
$image_data = file_get_contents($url);

$image = new Gmagick();
$image->readimageblob( $image_data );
// followed by this, just for testing:
header( 'Content-Type: image/png' );
$output = '/tmp/image'; // again simplified
$image->writeimage( $output );
echo file_get_contents( $output );

You can view the results at http://resizedev.exactlywww.com/test-png8.php

Of course, the actual code in production is doing some resizing and such,
otherwise we wouldn't bother loading an image with Gmagick in the first
place, but the above is sufficient to demonstrate the problem.

I'm wondering if it's related to an earlier conversation we had (related to
https://code.trac.wordpress.org/changeset/488/photon), or perhaps to this,
as it does appear to be an 8-bit PNG:
https://sourceforge.net/p/graphicsmagick/bugs/547/

Perhaps there is a workaround?

Thanks,
Shane

_______________________________________________
Graphicsmagick-help mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/graphicsmagick-help