pngcrush: uncrush on linux?

2.6k Views Asked by At

Apple's iOS SDK use a modified version of pngcrush for converting png files in iOS bundles. Their version can also revert the changes (using the "-revert-iphone-optimizations" switch), but the original version can't.

Is there a tool that can be run on Linux and revert the iphone optimizations?

Thanks.

2

There are 2 best solutions below

4
On BEST ANSWER

iphone-fixpng works in Linux. See this discussion explaining what it does. I'm linking to web.archive.org because the original is down.

1
On

You can choose to use one of this:

  1. Install Hackintosh inside linux, with VirtualBox. install Xcode inside it, then do something like this

    $ /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/pngcrush -dir uncrushed -revert-iphone-optimizations -q *.png
    

    This uses a modified pngcrush from apple to undo its optimizations. Guess this will work with all crushed pngs. See this for more accurated command xcrun

  2. Download iPIN.py from this blog and execute as

    $ python ipin.py
    

    This will uncrush all files from actual directory and its subdirectories. Don't worry about call it twice, from my experience does not corrupt already uncrushed pngs. From here you will find that ipin.py does not deoptimize all apple pngs

    It (ipin.py) cannot handle multiple IDAT chunks, does not work with Adam7 interlaced images, and does not fix pre-multiplied alpha.

  3. Use an specific gnome binary tool. This needs a few low level steps:

    $ git clone https://github.com/hadess/fixpng-thumbnailer.git
    $ cd fixpng-thumbnailer
    $ ./autogen.sh
    $ make
    $ sudo make install
    

    After that, you have available a new command gnome-fixpng-thumbnailer which works like this

    $ gnome-fixpng-thumbnailer [INPUT FILE] [OUTPUT FILE]

    Take care with this command, because it corrupts pngs if is called twice on same png.

    I use it this way:

    $ for file in *.png; do echo "   $file";gnome-fixpng-thumbnailer $file $file; done
    

    You will guess why echoed the filename. Thats because this command could fail silently, (no $? with nonzero if fails) and the only clue you will have is a "ZLib error! -3" message. It's a quick solution because funnily enough you will find ipin.py does uncrush those files.

Read this for yet another tool around pngdefry. It provides an invaluable info about all this stuff -even its source- but I haven't tried myself.

My hope is in pngcrush absorbs those functionality so you have it out of the box, at least I have send a mail to pngcrush maintainer (hi Glenn).