Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Compress all the PNG files in your Home directory UNIX
PNG image files are often not compressed with the optimal compression setting, however a one line command can fix this (and save some space).

Basically, one just needs to have MacPorts and the optipng port installed, and run the following command:
mdfind -0 -onlyin ~ "kMDItemContentType=public.png" | xargs -n 5 -0 optipng -preserve
For more details, see this blog entry.

[crarko adds: I haven't tested this one. Note that to use MacPorts you also need to have Xcode installed to compile the ports. If you already have MacPorts set up give this hint a try and let us know how efficient the compression is for you.]
    •    
  • Currently 2.17 / 5
  You rated: 1 / 5 (6 votes cast)
 
[4,160 views]  

Compress all the PNG files in your Home directory | 3 comments | Create New Account
Click here to return to the 'Compress all the PNG files in your Home directory' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Compress all the PNG files in your Home directory
Authored by: ManxStef on Nov 23, '11 07:53:34AM

You could also use the excellent, and free, ImageOptim to compress your PNGs, though you'll need to drag and drop instead. (Which is perhaps more wise than a blanket sweep.)

Its sister app ImageAlpha is great, too, very handy for generating IE6-compatible transparent PNGs without needing to resort to hacks/tricks, for those of us unfortunate enough to still support IE6 when building websites.



[ Reply to This | # ]
Compress all the PNG files in your Home directory
Authored by: arcticmac on Nov 23, '11 08:18:03AM

While this is true, you usually only save 5-20% on most images, and it's fairly CPU/time intensive. Unless you have a lot of PNG images and _really_ need the disk space, using optipng or pngcrush or any of the others probably isnn't worth the time.

Now, on the other hand, if you're a developer or a web designer and you're generating PNG images that will be distributed (hopefully) hundreds or thousands of times, then PNG optimization is absolutely for you. Just replace the "~" in the original poster's command with the path to one of your development directories.



[ Reply to This | # ]
Compress all the PNG files in your Home directory
Authored by: Lri on Nov 23, '11 11:10:34AM

If you keep any signed applications in ~/Applications/, running this will break their code signatures.



[ Reply to This | # ]