SkCodec can't read compressed png on iOS

53 views
Skip to first unread message

Matthew Leibowitz

unread,
Aug 19, 2016, 12:20:53 AM8/19/16
to skia-discuss
Is there something that I need to do to allow SkCodec to read a png that has been optimized?
I have attached the before and after images.

SkCodec can read "hamburger.png", but SkCodec::NewFromStream returns NULL when loading the "compressed.png"

hamburger.png
compressed.png

Matthew Leibowitz

unread,
Aug 19, 2016, 12:23:06 AM8/19/16
to skia-discuss
And, I just noticed that Chrome on Mac also can't display that image...

Matt Sarett

unread,
Aug 19, 2016, 9:03:19 AM8/19/16
to skia-discuss
The file that you've labeled as compressed.png is an "Apple optimized png".  It's a proprietary png format only supported by iOS.  We don't have plans to support this - Chrome and Firefox also don't support it.

A few major differences between "Apple optimized png" and regular png is that Apple pngs are stored BGRA (instead of RGBA) and are premultiplied.  This is to optimize the speed of decoding/loading of the image on iOS.  As far as I can tell, this doesn't really have anything to do with compression size.  Are the two images you sent identical (I can't open compressed.png)?  If so, it's worth mentioning that compressed.png is actually a larger file.

Below is a good resource explaining the iOS png.  And there's a lot more information out there if you search "Apple optimized png".

And here's a guide for how to convert Apple pngs to regular pngs:

Best,
Matt
Reply all
Reply to author
Forward
0 new messages