7

I have some png images extracted from IPA files and I want to get the original PNG back, I was advised that pngcush did the task required so I downloaded it and tried running the following command:

pngcrush -fix icon.png icon1.png

But I get a libpng error. I don't know if libpng needs to be downloaded as well, since the error doesn't says that I need a different version of libpng, just says:

While reading icon.png:
  pngcrush caught libpng error:
   incorrect header check

I also tried this one:

pngcrush -revert-iphone-optimizations icon.png icn1.png

And pngcrush acts as if didn't knew the command.

Any ideas on what to do?

Glenn Randers-Pehrson
  • 11,940
  • 3
  • 37
  • 61
David Conde
  • 4,631
  • 2
  • 35
  • 48
  • May you please provide a link to an "iphone-optimized" PNG so that we can test ? – Yves Martin Apr 10 '12 at 06:46
  • On Mac if you don't want to deal with Terminal you can use iPhonePNGApp. You just provide directory of your images and it converts all png images to normal format. Very simple. – Egis Mar 02 '15 at 13:53

4 Answers4

3

You may be interested in this C# library I developed to reverse what pngcrush does. All existing implementations I found were either riddled with bugs or too difficult to integrate into my project so I developed this. It has unit tests if that makes you feel safer.

The -iphone addition to pngcrush was added by Apple and is only available in the version of pngcrush in the iOS SDK, accessible by using xcrun like follows:

xcrun -sdk iphoneos pngcrush -iphone|-revert-iphone-optimizations ...
Mike Weller
  • 45,401
  • 15
  • 131
  • 151
2

This answer: pngcrush: uncrush on linux? explains that -revert-iphone-optimizations is only present in the Apple version of pngcrush. But it does point to a couple of other options that might work. Linux, not Windows, but since there's source, you might get it to work.

Community
  • 1
  • 1
Sparky
  • 8,437
  • 1
  • 29
  • 41
2

Maybe you can try pngdefry.

Perfect dealing pngs with multiple IDAT tags.

fancyPants
  • 50,732
  • 33
  • 89
  • 96
vivimice
  • 496
  • 8
  • 9
0

It probably doesn't know the command. The documentation I found on -revert-iphone-optimizations comes from an apple developer page which refers to pngcrush being a part of the IOS SDK. Given that, i'd suggest it's been hacked into that specific version by apple and may not be part of the official pngcrush download. If that's true you'll actually need to install that and use the included pngcrush as explained in the article.

I'm also a bit suss on the syntax used in that example. It looks like a long option and they normally start with two hythens, not one. It could simply be a typo so try --revert-iphone-optimizations as well.

SpliFF
  • 38,186
  • 16
  • 91
  • 120
  • sorry @SpliFF, it doesn't works out with the windows version of pngcrush, thanks for the help! – David Conde Apr 12 '12 at 04:53
  • yes, welcome to the world of apple/microsoft developer lock-in. your only real option seems to be finding someone with a mac. – SpliFF Apr 12 '12 at 07:11
  • actually I have two Macs, but I want to work this out as a Windows app. Since iTunes had it, I thought it may happen, then again, iTunes belongs to Apple, so they may be cheating.. ;) – David Conde Apr 12 '12 at 16:19
  • the problem as I see it is that apple have created a proprietary modification of pngcrush and the PNG format for the single purpose of lock-in ( apparently the "optimisations" are actually worse than those available via existing tools - http://imageoptim.com/tweetbot.html ). They're not going to tell anyone what they did so only reverse-engineering is going to bring format support to other platforms. I suspect you're SOL. – SpliFF Apr 13 '12 at 04:44
  • If that weren't bad enough ImageOptims claims that apple has patented the "optimisation" process they use. Since the format appears to be poorly optimised the only conclusion you can reach is that apple have done all this deliberately to prevent third-party iOS tools development. – SpliFF Apr 13 '12 at 04:52
  • Following the Vendor LockIn road... I think the iTunes SDK would possibly solve this: http://developer.apple.com/sdk/itunescomsdk.html – David Conde Apr 13 '12 at 14:22