I am using GraphicsMagick and currently running into the following issue:
when executing
gm identify <filename>.png
I'm getting the following error:
gm identify: CgBI: unknown critical chunk (<filename>.png)
gm identify: Request did not return an image.
This is a png extracted from an iPhone. Though it may not contain an actual image, I do need the image info.
Tried opening it with several editors:
The png does open in Paint with the right height x width but as completely white.
The png does not open in GIMP, saying it might be corrupted
The png does open in Paint.net with the right height x width as a transparent image
Using the debug parameter provides the following line:
libpng-1.5.14 error: CgBI: unknown critical chunk
I'm running the latest GraphicsMagick (1.3.18).
Does anyone know what's going on, and how I will be able to get this to return the image info?
Thanks in advance.
The PNG you are trying to read has been run through Apple's "Xcode" version of pngcrush, which creates files that aren't PNGs. I believe Apple's pngcrush also has the capability of undoing the damage and more-or-less restoring the original PNG, using the "-revert-iphone-optimizations" option, although it's not mathematically possible to restore the color channels exactly for transparent or semitransparent pixels.
set in xcode build setting this flag to NO
Remove Text Metadata From PNG Files = NO
Related
Every uploaded png file to CloudPebble gives me a Uncaught Error: Incomplete or corrupt PNG file error during an app run-time.
I tried to save png file in different formats, compression, no compression, gray scale, indexed Pebble colors, etc.
Cannot get it working. PNG file is simple black and white icon. Followed tips in the documentation for Image Resources.
What can be wrong?
It seems in my case it was a CloudPebble error that has been fixed. My app compiles now no problem.
For tips on images for pebble check https://developer.getpebble.com/blog/2014/10/29/Displaying-remote-images/
I am developing an app that downloads a png image from internet and displays it. For some reason gbitmap_create_from_png_data() fails to load most images with following error message:
[ERROR] gbitmap_png.c:49: PNG memory allocation failed
[ERROR] gbitmap_png.c:99: Failed to load PNG
I doubt that I am out of memory. I say this because I have tried loading very small images i.e 4Kb in size and they still fail. On the other hand some images, although 16kb in size, load successfully. Other confusing thing is that the same images that fail to load using gbitmap_create_from_png_data() load successfully using gbitmap_create_with_resource() if I add them as image resources to my app. So images are correctly formated for Pebble. The downloaded images are exactly the same size as the ones I have locally so I doubt the image data gets corrupted.
Successful image: http://brucedalemansion.com/images/baby_16.png
Un-Successful image: http://i.imgur.com/CUJwSU7.png
The un-successful image contained a transparency chunk (tRNS) with 0 entries. For the palette chunk (pLTE), this would be invalid by the specification. For the transparency chunk, it may be considered valid... as the PNG specification states "[equal] or less tRNS entries than there are palette entries".
Since some tool is making PNGs with this issue, I am adding support to our PNG decoder for it.
I would be interested in what tool made that PNG image.
Matt from Pebble
I am at a complete loss because my application icon simply will not register. I've tried just about everything and the icon still just will not register. I think it may have to do with the fact that I was trying to re-name my project something else, and perhaps the targets now do not match. Can anybody provide advice on why my icon simply will not show up on the phone?
Thanks
PNG compression is a little algorithm that the compiler performs to cut down on the space images take up in your app. Unfortunately, it has been the Bain of many a programmer's existence because it often doesn't de-compress the images once the binary is made and ran. Just set it to NO.
PNG compression also optimizes the PNG's for an iOS device like so:
Extra critical chunk (CgBI).
Byteswapped (RGBA –> BGRA) pixel data, presumably for high-speed >direct blitting to the framebuffer.
Zlib header, footer, and CRC removed from the IDAT chunk.
Premultiplied alpha (color′ = color * alpha / 255).
I'm making a Universal App using MonoTouch, and I'm adding my Default-Portrait.png file. That file alone (a 768x1004 .png file) is adding 711k to the size of the app. My app itself is only about 7 megs, so it's adding 10% just for the splash screen.
I could easily make this thing an 80k jpg file instead of a png, but the device doesn't seem to look for a .jpg file. Does anyone have tips for reducing the size of this launch art?
At this point, I'm thinking I might just leave the launch art out and load my own jpg and display it as soon as I have the ability to. That'll keep my app size down, but it's not as nice as having the launch art scale in immediately like most apps do.
Hmmm...given the screen of the iPad and the visual quality users are expecting, I'd just leave it like that.
But if you do want to reduce the disk space, try going to Project > Edit Project Settings > Build (tab at top), and searching for a parameter called "Compress PNG Files." Make sure that's checked. It'll run the pngcrush utility before loading the file onto disk (check the size of your IPA archive after to see if it had any effect).
pngcrush is nice as well, however that will not reduce the quality of you image. If reducing the quality of the image is an option for you, then you might try this tool: http://www.punypng.com/ - or just use an image editing tool to "optimize" the image ...
I recommend pngout if you want to really squeeze those PNGs down, and this won't cost you any quality. It simply removes unnecessary metadata (like pngcrush) and uses its own compression algorithm which is compatible with the regular decompressor used in PNG (zlib). It's really slow, though.
A simpler option is to try "Save for web" in your image manipulation program of choice. Exporting from Acorn (not just the regular save) sometimes gives me vastly smaller files. This is especially true for default images which have large, uniform areas in one colour (screenshots, a small logo in the middle of a black screen).
Is there any reason why you want to reduce the file size that badly? I don't think it matters in your case. I just checked 3 of my apps and the Default.png (of various portrait/landscape varieties) is between 29KB and 422KB, so whilst yours do seem a little heavy, your still way under the 3G download limit.
Are you positive it's adding that much to the size of the app? Did you compare a before and after?
Xcode uses pngcrush on the images for you. I know because I just tried to substitue jpegs for pngs and got the following result:
So, in short, there's not a lot to be done except simplify the image beforehand. Xcode will handle the rest.
Is it possible to set an iPhone Xcode project to skip the 'CompressResources' build step?
Specifically, I want to skip the stage where it runs pngcrush on all of my .png files, many of which don't survive the experience in a form which my app can read.
Edit: the version of pngcrush used creates png files which contain a non-standard 'mandatory, private' chunk which explicitly prevents decoding. I've modified my png reader to handle these files, but I'd still like a per-project method of skipping this step. One of the other side effects of pngcrush is that it doesn't save the colour value of transparent pixels, so alpha-ed textures show fringing at smaller mip levels.
The iphone png format is described here: https://web.archive.org/web/20110519164905/http://modmyi.com/wiki/index.php/Iphone_PNG_images. In short,
Skip the CgBI chunk
Skip the zlib headers
Swap BGR to RGB channel order
Edit: It appears it also premultiplies the alpha, so:
Divide by alpha
You can add "IPHONE_OPTIMIZE_OPTIONS=-skip-PNGs" to your project settings to prevent the png mangling, but be careful with it, you might need to optimize the icon and Default.png separately then.
The iphoneos-optimize script converts PNG files into a nonstandard format that is optimized for display on the iPhone. The script will convert any files with the png extension that it finds inside your app bundle.
I had a similar problem, and solved it by giving my file the extension _png (i.e., prefixed an underscore). iphoneos-optimize ignored it and left it a regular PNG file. If you can deal with it that way, it's probably a lot safer than mucking about with the build scripts.
Open build settings
Under "packaging" choose Compress PNG files
Choose "NO"
If you look at the build output you'll see that the CompressResources step runs the script /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/iphoneos-optimize. This appears to be just a shell script that runs pngcrush and compiles plists into binary format. You could probably modify this script to not run pngcrush.
Note that someone in this thread noticed that if they did not run their icon file through pngcrush it wasn't showing up on the phone.
Interestingly, the version of pngcrush in the directory of the script has a -iphone argument. Anybody know if this is standard or something Apple just ships with their build of it?
That might be another issue all together. In many cases the problem has to do with naming and can be solved very easily.
read this:
http://cocoapi.wordpress.com/2009/03/22/iphone-images-not-appearing-in-real-iphone-this-is-why/