Skip to content Skip to sidebar Skip to footer

How To Use Python To Imitate The Opening And Saving Of An Image File In An Image Editor?

I encountered a certain problem with corrupt .png image files* that I was able to overcome by simply opening them in an image editor (Apple's Preview) and saving them back, without

Solution 1:

Your example file, https://i.stack.imgur.com/a5uXX.png, isn't actually a PNG file. It's a "CgBI" file instead, which is a PNG-like file created by Apple X-code software, probably using their rogue "pngcrush" application. There are various ways of recovering a valid PNG file from a CgBI file (except for unavoidable loss of precision in the underlying color values of non-opaque pixels).

  • The Apple-modified pngcrush is itself capable of reverting the "iPhone optimizations"

  • There are third-party applications such as the public domain, open source pngdefry application that can be found on the net.

Apologies for not showing you how to invoke pngdefry or pngcrush via python calls, but hopefully this will set you on the right track, and at least tell you what has happened to your files.

Legal Notice: I am required to note that Apple and iPhone are registered trademarks of Apple, Inc.


Post a Comment for "How To Use Python To Imitate The Opening And Saving Of An Image File In An Image Editor?"