Re: Converting to PNG8 loses transparency
Glenn Randers-Pehrson <[email protected]> Thu, 20 Jun 2013 18:16:32 -0400
| Newsgroups | gmane.comp.video.graphicsmagick.tools |
|---|---|
| Message-ID | <CA+PdXcvFugGUOK9AgnsHOc7QRdUKbLcuJsicY3gtt_o_ODe51w@mail.gmail.com> |
--===============6277542242149057032== Content-Type: multipart/alternative; boundary=001a11c2acca7133b804df9d4c93 --001a11c2acca7133b804df9d4c93 Content-Type: text/plain; charset=ISO-8859-1 In GraphicsMagick, "PNG8" means indexed 8-bit PNG with optional binary transparency. PNG can represent 8-bit images with full transparency, but that is not what we call PNG8. "pngquant" is a handy third-party application that can reduce a 32-bit RGBA PNG image to 8-bit with full transparency (it reduces the palette to 256 or fewer RGBA entries, which are represented in PNG via the PLTE and tRNS chunks). You can get such 8-bit indexed images with full transparency via the -colors 255 option, etc, but not by using the PNG8: format descriptor. Note that PNG8 is not defined by the PNG specification but rather by various other parties. When we defined "PNG8" in GraphicsMagick, the target for such images was a major commercial browser that could not handle the tRNS chunk properly to decode and display full transparency. On Thu, Jun 20, 2013 at 12:18 PM, Kenneth Xu <[email protected]> wrote: > Hello, > > This may be a dumb question but I did google as well as searching archive > but cannot seem to find the answer. I'm trying to convert an PNG32 image to > PNG8 using command below: > > gm convert source.png png8:target.png > > The command is useful to us as it reduces the image size to half but still > yet good quality (see http://www.sitepoint.com/png8-the-clear-winner/). > The problem is any transparency in source image is lost in the target > image. The closest post I can find in the archive is this one: > http://sourceforge.net/mailarchive/message.php?msg_id=20516411, but it > was about creating an image. But that at least confirm that PNG8 in > graphicsmagick can support transparency.Also, http://tinypng.org/ was > able to do the same conversion but keeps the transparency intact, which > means this is doable. > > So what I'm doing wrong? Thank you in advance for you help.I can provide > test images if needed. > > Kenneth > > > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by Windows: > > Build for Windows Store. > > http://p.sf.net/sfu/windows-dev2dev > _______________________________________________ > Graphicsmagick-tools mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/graphicsmagick-tools > > --001a11c2acca7133b804df9d4c93 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr">In GraphicsMagick, "PNG8" means indexed 8-bit PN= G with optional binary transparency. =A0PNG can represent 8-bit images with= full transparency, but that is not what we call PNG8. =A0"pngquant&qu= ot; is a handy third-party application that can reduce a 32-bit RGBA PNG im= age to 8-bit with full transparency (it reduces the palette to 256 or fewer= RGBA entries, which are represented in PNG via the PLTE and tRNS chunks). = =A0You can get such 8-bit indexed images with full transparency via the -co= lors 255 option, etc, but not by using the PNG8: format descriptor. =A0Note= that PNG8 is not defined by the PNG specification but rather by various ot= her parties. =A0When we defined "PNG8" in GraphicsMagick, the tar= get for such images was a major commercial browser that could not handle th= e tRNS chunk properly to decode and display full transparency.</div> <div class=3D"gmail_extra"><br><br><div class=3D"gmail_quote">On Thu, Jun 2= 0, 2013 at 12:18 PM, Kenneth Xu <span dir=3D"ltr"><<a href=3D"mailto:sou= [email protected]" target=3D"_blank">[email protected]</a>></span= > wrote:<br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div><div><div>Hello,<br><b= r></div>This may be a dumb question but I did google as well as searching a= rchive but cannot seem to find the answer. I'm trying to convert an PNG= 32 image to PNG8 using command below:<br> <br></div>gm convert source.png png8:target.png<br><br>The command is usefu= l to us as it reduces the image size to half but still yet good quality (se= e <a href=3D"http://www.sitepoint.com/png8-the-clear-winner/" target=3D"_bl= ank">http://www.sitepoint.com/png8-the-clear-winner/</a>). The problem is a= ny transparency in source image is lost in the target image. The closest po= st I can find in the archive is this one: <a href=3D"http://sourceforge.net= /mailarchive/message.php?msg_id=3D20516411" target=3D"_blank">http://source= forge.net/mailarchive/message.php?msg_id=3D20516411</a>, but it was about c= reating an image. But that at least confirm that PNG8 in graphicsmagick can= support transparency.Also, <a href=3D"http://tinypng.org/" target=3D"_blan= k">http://tinypng.org/</a> was able to do the same conversion but keeps the= transparency intact, which means this is doable.<br> <br></div><div>So what I'm doing wrong? Thank you in advance for you he= lp.I can provide test images if needed. <br><span class=3D"HOEnZb"><font co= lor=3D"#888888"><br></font></span></div><span class=3D"HOEnZb"><font color= =3D"#888888"><div> Kenneth<br></div><div><br></div></font></span></div> <br>-----------------------------------------------------------------------= -------<br> This SF.net email is sponsored by Windows:<br> <br> Build for Windows Store.<br> <br> <a href=3D"http://p.sf.net/sfu/windows-dev2dev" target=3D"_blank">http://p.= sf.net/sfu/windows-dev2dev</a><br>_________________________________________= ______<br> Graphicsmagick-tools mailing list<br> <a href=3D"mailto:[email protected]">Graphicsmagic= [email protected]</a><br> <a href=3D"https://lists.sourceforge.net/lists/listinfo/graphicsmagick-tool= s" target=3D"_blank">https://lists.sourceforge.net/lists/listinfo/graphicsm= agick-tools</a><br> <br></blockquote></div><br></div> --001a11c2acca7133b804df9d4c93-- --===============6277542242149057032== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ------------------------------------------------------------------------------ This SF.net email is sponsored by Windows: Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev --===============6277542242149057032== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Graphicsmagick-tools mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/graphicsmagick-tools --===============6277542242149057032==--