Search code examples
terminalpngpngcrush

Can someone please explain clearly how to use "pngcrush" for multiply items


I have a stack of hundreds of pictures and i want to use pngcrush for reducing the file sizes.

I know how to crush one file with terminal, but all over the web i find parts of explanations that assume previous knowledge.

can someone please explain how to do it clearly.

Thanks Shani


Solution

  • You can use following script:

    #!/bin/bash
    
    # uncomment following line for more aggressive but longer compression
    # pngcrush_options=-reduce -brute -l9
    find . -name '*.png' -print | while read f; do
      pngcrush $pngcrush_options -e '.pngcrushed' "$f"
      mv "$f" "${f/%.pngcrushed/}"
    done