PNG Compression [closed]
Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question 开发者_开发百科Some PNG images although just 150px x 160px wide have 60KB filesize. I've already run them though optimizers (ImageOptim for Mac) but that didn't help much.
Is there any way to compress it further, either manually or using some other tool? 60KB for a normal 150x160 image is really unacceptable and I can't use JPG or GIF there because I need transparency.
I tried exporting the PNGs as 8-bit PNG and the filesize has reduced significantly!
This has to do with how PNG compression works.
Unlike JPEG, PNG is a lossless format, position-wise, but not necessarily color-wise.
That is - while JPEG stores transitioning of colors from one area to another, PNG stores the data pixel by pixel and then losslessly compresses this data.
The difference between GIF and PNG actually comes from traditional conventions -- GIF was traditionally saved as 8-bit whereas PNG, which came later, was often saved as 32-bit (true color + alpha/transparency). So, the 32-bit image will require four times as much uncompressed data per pixel, and depending on the specifics of the image, the more detailed the data, the worse it compresses losslessly.
Hence, if you were to compare a 8-bit PNG to a 8-bit GIF, the file sizes should be very similar. The same applies with true color PNG vs true color GIF. This explains why selecting the 8-bit option will solve the file size issue. Otherwise, it's effectively a compressed BMP.
Have you tried PNGOUT?
Tried exporting the same PNGs as 8-bit PNG and the filesize has reduced significantly.
Steps:
- Open the PNG in Photoshop
- File > Save for Web and Devices
- Select "PNG-8 128 Dithered" from the "Preset" dropdown
- Save
Reduced a 31kb image to 10kb.
There are a couple of good articles on Smashing Magazine about optimizing PNG images, Clever PNG Optimizaiton Techniques and PNG Optimization Guide: More Techniques. These focus on manipulations you can do to the source image to make them work better for PNG compressors.
Beyond that, I'd recommend a tool like OptiPNG or PNGCRUSH.
Yes, you can make PNG 60-70% smaller with pngquant. There's a Mac GUI for it.
It works by converting RGBA PNG to 8-bit paletted PNG, but, unlike Photoshop, it keeps the alpha channel.
We faced similar problems/questions in most of our latest website projects and developed a solution via PHP, .htaccess and Javascript. I wrote two articles about the theory (part 1: "shrinkImage - A method to reduce the filesize of PNG-images with full alpha-channel by about 70-80%") and the practical jQuery plugin we ended up with (part 2: "shrinkImage continued - jQuery plugin and automatic generation").
If the background of your question is use on a webserver, it might be an option to check it out.
Background (in short) of our solution is to split the alpha channel from the rest of the image and save it as a rather small PNG, save the color information as JPEG with variable compression and store both as JSON file on our server which is requested and processed by the jQuery plugin via HTML5 Canvas (if supported, otherwise the plugin gracefully falls back to the original PNG).
Hope this helps you or anybody else facing the same problem, even though the question is rather old :)
It's already been referenced in a comment, but it deserves an answer of its own. Just downloaded PNG Gauntlet. It's just what I needed, as someone who really doesn't want to learn command line switches and PNG options: a simple, very easy-to-use Windows utility where you just add your images and click on a button.
I get the impression from reading other sites that it's not the world's fastest tool, but this isn't an issue for me (once you've got the compressed image, you're sorted).
First file was reduced from 126k to 47k, which will do for me.
精彩评论