Support Forums

Full Version: PNG End Bytes Significance?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
What's the significance of these 12 bytes in the PNG file format?

Code:
0x00 0x00 0x00 0x00 0x49 0x45 0x4E 0x44 0xAE 0x42 0x60 0x82

I don't understand, from what i've read, it is a critical part of the file, however when removed, it has no barrier on whether or not you're able to open/view and/or edit the file whatsoever.
No replies to my post at all?...
(01-01-2012, 07:21 AM)AceInfinity Wrote: [ -> ]No replies to my post at all?...

That would be because no one has any freakin clue as to a likely reason for this. You're too curious. Non
Yeh I haven't got the slightest idea what you're on about.
lol times when I wish there were more programmers on a forum I frequently visit... What i'm doing is recursively searching through the bytes of a filetype and using List(of Object) to add each byte from the file and search for specific bytes in a newly instanced byte array, I have to convert the encodings, and search for this end statement. After removing specific chunks of bytes as arbitrary data in the file it's going to be parsed back into a byte stream as a pseudo recompiler so I can optimize the filesize on disk. Dealing with large data like this though may require extensive multi-threading operations.

In sum this is information I require to further my development on a programming project.

What those bytes above represent is the last 12 bytes of all PNG files.
No offence but that sounds really really boring. But hey what do I know, I'm sure it's useful. Good luck with your project.
(01-01-2012, 06:13 PM)Fragma Wrote: [ -> ]No offence but that sounds really really boring. But hey what do I know, I'm sure it's useful. Good luck with your project.

Boring because you don't understand or you don't like dealing with bytes? Not everything in programming is going to be flashy like graphics Smile

So far i'm able to remove 2 types of byte chunks in the PNG file format, which gets me about 30-50 bytes less than the original filesize. Still more to go, but PNG is already a fairly minimal filetype. There's not much you can do with compressing it's data.

Edit:
pHYs: *Total Byte Capacity = 21
Code:
0x00 0x09 0x70 0x48 0x59 0x73 0x00 0x00

cHRM: *Total Byte Capacity = 44
Code:
0x00 0x20 0x63 0x48 0x52 0x4D 0x00 0x00

Basically in sum along with those 12 in the last 12 bytes of the file allow me to optimize the file by a difference of 77 bytes, not 30-50. Soon i'll be able to downsize by over 1kb, but with very small graphics that can be a big difference. There's not all the byte chunks stored in smaller graphics though due to the lack of color values in each pixel, but if you're doing this with every file you have on your website it can make a difference. Omni here wants userbars to be under 3kb? 4kb? I can't remember, but here's a use for that as well.
Sorry, that went straight over my head. Only because I couldn't be fudged to read it right now. It's good that you have such knowledge, though. Smile
I'm now at a point where i've been able to compress PNG files by a difference of 200 bytes, however there's still text data chunks and a photoshop iCCP profile that i've seen in some of my own personal PNG files that I used for debugging that I don't know what to deal with. If I could remove that photoshop data with all it's bytes and all the meta data associated with it I could potentially reduce the file by another 200 bytes on top of that depending on whether or not it exists within the byte structure.

I could also take out the transparency chunks which is only about 1 byte difference in file optimization so I felt it's not really worth it. Transparency actually doesn't make a big difference in PNG file size after my investigation... Unless you care about getting rid of an extra whopping 1 byte.

Here's what i've got so far:
Code:
(pHYS):
    HEX Signature = [0x00 0x09 0x70 0x48 0x59 0x73 0x00 0x00]
    DEC Value = [0x0 0x9 0x112 0x72 0x89 0x115 0x0 0x0]
        *Total byte capacity = 21
        *Remove 13 more bytes starting after the signature

Code:
(cHRM):
    HEX Signature = [0x00 0x20 0x63 0x48 0x52 0x4D 0x00 0x00]
    DEC Value = [0x0 0x32 0x99 0x72 0x82 0x77 0x0 0x0]
        *Total byte capacity = 44
        *Remove 36 more bytes starting after the signature

Code:
(gAMA):
    HEX Signature = [0x00 0x04 0x67 0x41 0x4D 0x41 0x00 0x00 0xB1 0x8F 0x0B 0xFC 0x61 0x05 0x00 0x00]
    DEC Value = [0x0 0x4 0x103 0x65 0x77 0x65 0x0 0x0 0x177 0x143 0x11 0x252 0x97 0x5 0x0 0x0]
    Length: 1 byte

Code:
(sRGB):
    HEX Signature = [0x01 0x73 0x52 0x47 0x42 0x00 0xAE 0xCE 0x1C 0xE9 0x00 0x00 0x00]
    DEC Value = [0x1 0x115 0x82 0x71 0x66 0x0 0x174 0x206 0x28 0x233 0x0 0x0 0x0]
    Length: 1 byte

Code:
(bKGD):
    HEX Signature = [0x06 0x62 0x4B 0x47 0x44 0x00 0xFF 0x00 0xFF 0x00 0xFF 0xA0 0xBD 0xA7 0x93 0x00 0x00 0x00]
    DEC Value = [0x6 0x98 0x75 0x71 0x68 0x0 0x255 0x0 0x255 0x0 0x255 0x160 0x189 0x167 0x147 0x0 0x0 0x0]
    Length: 6 bytes

Note the mid value bytes for 0xFF 0xFF 0xFF represent the background color in RGB format in hexadecimal form, hence why you now start to see some real values being the 255 max in the decimal version I found. The background image of the file I examined here was white.

Code:
(vpAg):
    HEX Signature = [0x00 0x09 0x76 0x70 0x41 0x67 0x00 0x00 0x00 0x10 0x00 0x00 0x00 0x10 0x00 0x5C 0xC6 0xAD 0xC3 0x00 0x00]
    DEC Value = [0x0 0x9 0x118 0x112 0x65 0x103 0x0 0x0 0x0 0x16 0x0 0x0 0x0 0x16 0x0 0x92 0x198 0x173 0x195 0x0 0x0]
    Length: 9 bytes

These are all demos of what i've extracted from my own personal debugging and testing, variable bytes do change but the signatures for each of these arbitrary byte chunks do not, which is why they are identifiable.

Now onto moving how I can modify the critical sectors of the PNG file structure with each of the IDAT chunks. All of what I did so far however, results in no lossy compression. It's all useless data kept in the background that most people wouldn't even realize was there in the first place.
Okay, you're just talking to yourself now. :p
Pages: 1 2 3