View Full Version : Why PNG is so big ?
yanuart
08-08-2005, 08:03 AM
I just realize that a 1024x1024 PNG file sized more than 4MB !! That's alot bigger than other compressed graphic file format. But there's no other option since I need PNG for its transparency so now I can't downsize my game below 10MB barrier.
Is there any other file format for graphic that has transparency but very small in size ?
digriz
08-08-2005, 08:07 AM
Have you tried the palettised png with alpha. That should get the file size down.
Have a look at pngquant on the net...It will do the converting for you.
Or see how you get on with jpg.
James C. Smith
08-08-2005, 08:08 AM
You could always store the transparency information in a different file. Or make up your own file format. This has been discussed many times. Try searching.
Here is one of the many existing topics that touch on this: PNG with alpha (http://forums.indiegamer.com/showthread.php?t=3121&page=1&pp=30)
revve
08-08-2005, 08:10 AM
Try http://brh.numbera.com/software/pnggauntlet/ - always work on a copy of your images.
ChilledOut
08-08-2005, 08:29 AM
Also try pngcrush (http://pmt.sourceforge.net/pngcrush/).
Bad Sector
08-08-2005, 08:32 AM
Ken Silverman's PNGOUT (http://www.advsys.net/ken/util/pngout.exe) seems to offer the best PNG compression out there. Here is a tutorial (http://www.advsys.net/ken/util/pngout.htm) describing it's usage, a review (http://www.twilightuniverse.com/2003/09/ping/) and here is a Linux version (http://jonof.edgenetwork.org/pngout) if you use the penguin OS :D.
Savant
08-08-2005, 08:42 AM
Bad Sector
The PNGGauntlet linked above uses PNGOUT as the back end so it's really the best of both worlds - a good UI and a good compression routine.
Bad Sector
08-08-2005, 08:46 AM
Really? In the review i give, PNGGauntlet has less score than PNGOUT... but they may used an older version of PNGOUT with PNGGauntlet when the review was written... and the review is 1 years old :-)
ggambett
08-08-2005, 09:18 AM
Others have replied about the solutions (I do what James says, color data as JPEG and alpha data as 4 bit BMP). Now the other part of your question, WHY. Without getting into a lot of detail : PNG uses a generic compression algorithm (in fact it uses zlib, the same as ZIP). A generic algorithm must compress and decompress files "perfectly", because it doesn't know what is it compressing so it can't asume anything is redundant data. For example, when you compress an EXE, you need the decompressed version to be bit-identical to the original. This is lossless compression.
On the other hand, when you know the kind of data you're compressing, you can make some assumptions - that's why JPEG compresses images so well, or why OGG compresses music so well. It's because they know they're compressing images or music so they can discard data a human being won't notice missing anyway. This is lossy compression.
PNG uses lossless compression even though it's dealing with images. That's why a 1024x1024x32bpp uses 4 MB (it seems you're using an uncompressed PNG!).
Savant
08-08-2005, 09:53 AM
Let me throw in a big "thumbs up" for PNGGauntlet, mentioned above. It took my existing PNG files down another 30-40% on average. Nice!
yanuart
08-08-2005, 10:42 AM
PNG uses lossless compression even though it's dealing with images. That's why a 1024x1024x32bpp uses 4 MB (it seems you're using an uncompressed PNG!).
what's so weird is that actually I don't mind if the file is big as long after I compress it (ZLIB) I'll get a smaller file but the PNG stays the same size after I zip it
soniCron
08-08-2005, 10:52 AM
what's so weird is that actually I don't mind if the file is big as long after I compress it (ZLIB) I'll get a smaller file but the PNG stays the same size after I zip it PNG and ZIP files are both compressed using the same algorithm. And as you're probably aware, zipping a zipped file again won't decrease the file size any further. Often, it'll actually increase the size! Because you're essentially zipping an already zipped file, your results will be negligible. If you're able to use an LZMA compression for your installer (NSIS (http://nsis.sourceforge.net/) and Inno Setup (http://www.jrsoftware.org/isinfo.php) support LZMA compression), you'll notice the best lossless image compression when using TGA files, because they haven't been previously compressed like PNGs are.
Try pngquant. (Be sure to keep the tRNS chunk and the palette order if you re-crush it [eg pngout /f0 /c3 /k1 /kp /d8 in.png out.png])
Other things you might want to try are rgb and alpha in seperated files (eg jpg for rgb and grayscale jpg or grayscale png for alpha).
If you're using an installer with LZMA compression (eg nsis) you should also try png without compression. If its an indexed image you should keep it 8bit even if the number of colors would allow 4bit. Thats a bit counter intuitive, but on average its about 5% smaller.
You can also just use an uncompressed image format (bmp/tga) like soniCron suggested.
If you can show us the image, I could be a bit more specific.
ggambett
08-08-2005, 12:24 PM
what's so weird is that actually I don't mind if the file is big as long after I compress it (ZLIB) I'll get a smaller file but the PNG stays the same size after I zip it
Then it is compressed PNG, but a hard to compress PNG at that. The more random-like an image is, the harder to compress. Think random stereogram vs picture with big, flat regions.
vBulletin v3.6.0, Copyright ©2000-2008, Jelsoft Enterprises Ltd.