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.