Of course, it’s undefined as to what happens when you make a GIF without a color table at all. It’s mentioned in the standard that it is optional to have a global color table. The compression algorithm wasn’t designed to compress a single byte very well.Ī single byte with a hex value of 3B ( in ASCII) indicates the end of the GIF.īased on the required structures for a transparent GIF, it turns out that 43 bytes is pretty close to as small as you can get.īut, I managed to figure out one trick to make it a bit smaller. It takes 5 bytes to represent the single pixel the image has in it. In the above file, the position is 0,0 and the size is 1x1. Each image block has a position and size within the overall image size. Used to indicate that the second color in the color table should be treated as transparent (can also be used for animation parameters, but isn’t in this file).Ī GIF file can actually contain multiple “images” within it, which keeps you from having to specify image data for parts of the image which have the same color as the background color. In our file, the first color is white an the second color is black. There are 2 colors in the global color table, the second one should be used as the background color.Ĭonsists of 3 bytes per color, a byte for red, green, and blue, respectively.Without going into too much detail, this section of the file indicates the following: He goes even smaller by first removing the transparency, then the color table.Ĭonsists of the bytes “GIF” and the version number, which is usually 89a. His solution for the transparent.gif would be 37 bytes: data:image/gif base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw= This guy breaks down the problem via the GIF spec.
0 Comments
Leave a Reply. |