Software for creating PNG 8-bit transparent images

10,218

Solution 1

I also needed a Linux solution and found pngnq to do a pretty good job. It seems to be designed specifically for creating 8-bit PNG images with alpha channels.

apt-get install pngnq # If on Ubuntu/Debian

Solution 2

The link you provided references ImageMagick, which is an excellent toolkit for manipulating images on Linux.

Solution 3

It depends on what exactly your original images look like.

If your images already contain 256 or fewer colors (RGBA values), you need only look at pngout (Windows) (Linux/BSD/Mac OS X ports), which you should already be using to optimize your PNG images anyway. It can't quantize images, but it can save them as 8-bit, including alpha transparency. Just pass in the /c3 (or -c3 on Linux et al.) color option to force it to save the image as PNG8.

If your images do contain more than 256 colors, you have a few more, but all less than perfect options:

  • Adobe Fireworks is probably the best option in terms of the resulting image quality. It will do the job if you only need to convert a few images, or if you don't mind relying on Fireworks to do the batch processing. I did find that it sometimes somehow limits the number of colors in the palette, creating a worse quality image than necessary. I don't know if that's perhaps a bug in CS3 that's been fixed in CS4.

    If you're not on Windows or OS X this obviously isn't an option, and buying Fireworks just for this probably isn't worth it either.

  • The only alternatives I know of are the already mentioned pngquant and pngnq. I've had better luck with pngnq, but that's probably just going to depend on which quantization strategy works best on the files you're working with.

    Unfortunately, I've noticed that neither of them work very well with small amounts of transparency (say, an opaque image with transparent, rounded corners).

Solution 4

Ah, if I remember correctly, when I have read this article some months ago, pngquant hadn't a Windows version. I see it has one now. So I tried it, and pngnq too.

The latter seems to do a slightly better job on the IceAlpha.png test image (from libpng.org), at the cost of a slightly bigger image (it can be post-processed with pngcrush or pngout anyway).

The dithering algorithms (the two of pngquant, the only one of pngnq) are different, and it might be worth having both tools, converting images with all algorithms and see what looks the best.

For the record, on the Windows side, IrfanView (4.10) displays these images very well (using the transparency level on each palette entry) while XnView (1.85.1) and GIMP (2.4) apply only a full transparency/opaque display, à la GIF: the light bulb given as an example in the linked article has a transparent background around it, but the orange part is fully opaque.

And the excellent utility TweakPNG shows we have a PLTE (palette, 222 entries) chunk and a tRNS (alpha values for palette colors, 222 entries) chunk. Even more, it allows to edit each palette entry, color and alpha level. It might be an interesting complementary tool for this format.

Note on IrfanView support: if it handles PNG8 correctly for transparency, it doesn't handle gamma information in PNG files: on the toucan image or the ping-pong image, I had to apply a gamma of 2.4 to get similar (lighter) colors.

Note also that IrfanView does an awful job of converting 32-bit PNG images to 256, allowing only one transparent color, which looks bad if full color was dithered!

I see that the GIMP manual states: "his “PNG8” format, like GIF, uses only one bit for transparency; only two transparency levels are possible, transparent or opaque. " while the ISO/W3C standard states: "The tRNS chunk specifies either alpha values that are associated with palette entries (for indexed-colour images) or a single transparent colour (for greyscale and truecolour images).". The PNG specification 1.2 added: "Although simple transparency is not as elegant as the full alpha channel, it requires less storage space and is sufficient for many common cases." It looks like the unique transparent color is more implemented than the full transparency palette, alas. At least browsers get it right.

Solution 5

For Mac: ImageOptim and ImageAlpha are GUIs that run pngcrush, pngquant, and various other normally command-line compression utilities. http://pngmini.com/

Share:
10,218
grom
Author by

grom

Working with: Cassandra Kafka ElasticSearch Java Python

Updated on June 04, 2022

Comments

  • grom
    grom almost 2 years

    I'm looking for software to create PNG8 format transparent images as per this article.

    NOTE: I need a Linux solution myself, but please submit answers for other OSes.

  • grom
    grom over 15 years
    Yeah I usually use GIMP, but in that article it says "I can certainly confirm that none of PhotoShop, Gimp, Paintshop Pro, or Xara has this functionality built-in."
  • Jordan Parmer
    Jordan Parmer over 15 years
    The following article suggests that PNG8 is the default for GIMP, but I may very well be wrong with that. It looks like some other people have good suggestions too. docs.gimp.org/en/gimp-images-out.html
  • grom
    grom over 15 years
    I tried using Image Magick as per the comment but the resulting image was messed up
  • grom
    grom over 15 years
    Although GIMP lets you created index PNG (ie. PNG8) it doesn't support having alpha channel for one or more palette entries. So unable to achieve the effect as per the article.
  • PhiLho
    PhiLho over 15 years
    Note the page you link to states: "More, this “PNG8” format, like GIF, uses only one bit for transparency; only two transparency levels are possible, transparent or opaque." Looks like somebody is mistaken here.
  • Luke
    Luke almost 15 years
    It doesn't use 1 bit for transparency. It uses one index (one color) as the designated transparent color. Usually you'd choose index 0 or index 255 (depending of the number of colors you're using) as the transparent color.
  • davr
    davr over 14 years
    I don't think Image Magick supports 8-bit PNG with more than 1-bit alpha transparency. At least I couldn't figure out how to make it generate them.
  • davr
    davr over 14 years
    Luke: It is possible, but not common, to have full alpha transparency, eg up to 255 levels of partially transparent image, in PNG8 format images. That's what he's asking about. GIMP does NOT support generating this type of image...if you convert down to an indexed image, it only gives you on/off transparency, not a whole range of levels.
  • Makyen
    Makyen over 5 years
    Please don't be the first to edit closed questions when your edit doesn't make the question reopen-able (i.e. doesn't make it on-topic). Questions get one and only one free entry-by-edit into the reopen queue. Your edit here usurped the OP's opportunity to easily get their question seen by people who might vote to reopen, in order to make an edit that was just correcting grammar. Yes, if the question is open, or if you weren't the first user to edit the question after it was closed, or if you voted-to-close, then, great, fix the post's grammar.
  • Makyen
    Makyen over 5 years
    But, when your edit would be the first one after closure and you didn't vote-to-close, then please don't make such edits, unless they make the question something that should be reopened. [Please ping me here once you've read these comments so I can delete them, as they have nothing to do with this post.]