views:

3360

answers:

7

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.

A: 

I recommend "The GIMP" as it is possible to output in PNG8 and supports Linux/Windows. If you want a quick Windows-only solution, I also recommend IrfanView.

j0rd4n
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."
grom
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. http://docs.gimp.org/en/gimp-images-out.html
j0rd4n
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.
grom
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.
PhiLho
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.
Luke
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.
davr
+1  A: 

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

Wyatt
I tried using Image Magick as per the comment but the resulting image was messed up
grom
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
+3  A: 

pngquant does a good job of converting to PNG8 while preserving full transparency.

If you're size-conscious, you may also be interested in pngcrush, which can usually (losslessly) compress PNGs quite a bit.

I'll also recommend pngout; it tends to beat almost every other optimizer in my experience due to its custom DEFLATE library.
Dark Shikari
Wow. Just tried pngout, and it blew the doors off what libpng generates. I wish the dude would release his custom zlib...
+1  A: 

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 (can be post-processed with pngcrush or pngout anyway). The dithering algorithms (the two of pngquant, the only one of pngnq) are different, 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) display very well these images (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 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. Might be an interesting complementary tool for this format.

Note on IrfanView support: if it handles correctly PNG8 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 32bit PNG image 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 spec. 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.

PhiLho
+1  A: 

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 PNGs anyway. It can't quantize images, but 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 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).

mercator
A: 

Microsoft Windows: Ultimate Paint (freeware and shareware versions are available).

Both versions can save as an 8 bit transparent PNG image.

It can also save as a 4 bit PNG (16 colours). This cuts the file size in half compared to 8 bit.

Input formats include BMP, GIF, ICO, JPG/JPEG and PNG.

The freeware edition of Ultimate Paint Standard 2.88 LE can be downloaded directly from http://www.ultimatepaint.com/up.zip (1.7 MB).

Peter Mortensen
+3  A: 

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's with alpha channels.

apt-get install pngnq # if on ubuntu/debian

Ben Hardy