Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > macOS > pngcrush ! Great cli program for optimizing your png files!

pngcrush ! Great cli program for optimizing your png files!
Thread Tools
OoklaTheMok
Dedicated MacNNer
Join Date: Feb 2000
Location: Sherman Oaks, CA
Status: Offline
Reply With Quote
Jun 14, 2002, 03:17 PM
 
if you use Save For Web in photoshop, a GIF file will always be smaller than a PNG-8 file of identical options. Now...this isn't any good reason to be using PNGs if a GIF does the exact same thing.

Anyway I went out searching for how to optimize pngs and found the program <a href="http://pmt.sourceforge.net/pngcrush/" target="_blank">pngcrush</a>... here's its startup options:

usage: pngcrush [options] infile.png outfile.png
pngcrush -e ext [other options] files.png ...
pngcrush -d dir [other options] files.png ...
options:
-already already_crushed_size [e.g., 8192]
-bit_depth depth (bit_depth to use in output file)
-brute (Use brute-force, try 114 different methods [11-124])
-c color_type of output file [0, 2, 4, or 6]
-d directory_name (where output files will go)
-double_gamma (used for fixing gamma in PhotoShop 5.0/5.02 files)
-e extension (used for creating output filename)
-f user_filter [0-5]
-fix (fix otherwise fatal conditions such as bad CRCs)
-force (Write a new output file even if larger than input)
-g gamma (float or fixed*100000, e.g., 0.45455 or 45455)
-iccp length "Profile Name" iccp_file
-itxt b[efore_IDAT]|a[fter_IDAT] "keyword" "text"
-l zlib_compression_level [0-9]
-loco ("loco crush" truecolor PNGs)
-m method [0 through 200]
-max maximum_IDAT_size [default 8192]
-nofilecheck (do not check for infile.png == outfile.png)
-n (no save; does not do compression or write output PNG)
-plte_len n (truncate PLTE)
-q (quiet)
-reduce (do lossless color type or bit depth reduction)
-rem chunkname (or "alla" or "allb")
-replace_gamma gamma (float or fixed*100000) even if gAMA is present.
-res dpi
-save (keep all copy-unsafe chunks)
-srgb [0, 1, 2, or 3]
-text b[efore_IDAT]|a[fter_IDAT] "keyword" "text"
-trns_array n trns[0] trns[1] .. trns[n-1]
-trns index red green blue gray
-v (display more detailed information)
-version (display the pngcrush version)
-w compression_window_size [32, 16, 8, 4, 2, 1, 512]
-z zlib_strategy [0, 1, or 2]
-zmem zlib_compression_mem_level [1-9, default 9]
-zitxt b[efore_IDAT]|a[fter_IDAT] "keyword" "text"
-ztxt b[efore_IDAT]|a[fter_IDAT] "keyword" "text"
-h (help and legal notices)
-p (pause)

anyway...using this program I was able to save 25-30% size from all my PS-generated PNGs, and every one was smaller than the corresponding GIF.

You can get the OS X binary here
<a href="http://us.dl.sourceforge.net/sourceforge/gnu-darwin/direct_download/packages/ppc/graphics/" target="_blank">http://us.dl.sourceforge.net/sourceforge/gnu-darwin/direct_download/packages/ppc/gra phics/</a>

Oh also...Save For Web and normal photoshop save as (in PS 6-7) makes PNGs that are too dark. Using the "-rem alla" option fixed this problem in all my pngs. Not sure if this is a gamma issue or ICCP issue.

<small>[ 06-14-2002, 03:38 PM: Message edited by: OoklaTheMok ]</small>
     
benh57
Senior User
Join Date: Aug 2001
Location: CA
Status: Offline
Reply With Quote
Jun 14, 2002, 10:53 PM
 
Looks useful, i'll see about making a Fink package for it as well.
Dual 800 - GF3 - 1.5GB
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 07:51 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,