an0
an0

Reputation: 17530

What's so special about this PNG file?

This PNG file can not be uploaded from my app to a 3d-party server. It always reports this error:

does multipart has image?

I'm sure multipart encoding is correct. Tens of thousands of images are uploaded from my app without this issue. It it the first time.

I guess there is something special about this PNG file and I proved it:

  1. Dropbox iOS app can not display the image.
  2. Tweetbot can not upload it. The error message is "media type unrecognized".

So this PNG file is indeed special and quite some apps and servers don't handle it properly. But I don't know what's so special about it and hope someone who know PNG better than me can help. Thanks.

Upvotes: 2

Views: 1226

Answers (1)

Glenn Randers-Pehrson
Glenn Randers-Pehrson

Reputation: 12455

It is a CgBI file, not a PNG, most likely made with Apple's rogue modified pngcrush.

Such files always contain "CgBI" in bytes 12-15, where "IHDR" belongs.

CgBI files can be converted to valid PNG files (except that the transparent areas are irreparably damaged) by several applications, including

  • Jongware's pngdefry
  • Apple's "pngcrush" (but not the real pngcrush)
  • others listed on the above-referenced CgBI wiki page

Here are the first few bytes in your file:

$ od -c test.png | head -4
0000000 211   P   N   G  \r  \n 032  \n  \0  \0  \0 004   C   g   B   I
0000020   P  \0     002   + 325 263 177  \0  \0  \0  \r   I   H   D   R
0000040  \0  \0  \0   `  \0  \0  \0   `  \b 006  \0  \0  \0 342 230   w
0000060   8  \0  \0  \0       c   H   R   M  \0  \0   z   %  \0  \0 200

Those bytes represent the following:

PNG signature 0-7
CgBI length 8-11
"CgBI" 12-15
CgBI data 16-19
CgBI CRC 20-23
IHDR length 24-27 (should be in 8-11)
"IHDR" 28-31 (should be in 12-15)
width 32-35 (should be in 16-19)
height 36-39 (should be in 20-23)
bit depth 40 (should be in 24)
color type 41 (should be in 25)
compression 42 (should be in 26)
filter method 43 (should be in 27)
interlace method 44 (should be in 28)
IHDR CRC 45-48 (should be in 29-32)
...

Upvotes: 3

Related Questions