So, I needed to find the starting and ending bytes for images and I would like to save them somewhere. Why not here? Please let me know if I need to or can make changes to the table. If we can get the end of file bytes, it will make extraction and manipulation in documents easier.
The starting bytes are well documented but the end bytes are not.
Here is what I found regarding the common formats.
Image Type | Start Bytes | End Bytes | Start Word | End Word |
---|---|---|---|---|
JPEG | 0xd8 0xff | 0xff 0xd9 | ||
PNG | 0x89 0x50 0x4E 0x47 0x0D 0x0A 0x1A 0x0A | 0x49 0x45 0x4e 0x44 | –Specs– | IEND |
GIFF | 0x47 0x49 0x46 0x38 | 0x3B | GIF87a | GIF9a | ; [9 bit ending is 101h] |
TIFF-Motorola | 0x4d 0x4d 0x00 0x2a | MM | ||
TIFF-Intel | 0x49 0x49 0x2a 0x00 | II | ||
PGM2 | 0x50 0x35 | P5 | ||
PLain PGM | 0x50 0x32 | P2 | ||
PBM | 0x42 0x4D | P1 | ||
BMP | 0x42 0x4D | BM |
*A GIF also marks itself by its format (7a or 9a to form the workd GIF8[format] in its magic number) and the end appears to be 101h with a EOF of 0x3B but this is a bit weird.
*The TIFF formats are apparently Big Endian for Motorola and Little Endian for Intel.
* The best statement I could find for a Tiff is that “Each strip ends with the
24-bit end-of-facsimile block (EOFB)” from a document refering to TIFF 1.0.
*A JPEG may also have the JFIF structure and be discoverable this way since JFIF is usually the first noticeable part of the image when converted to a string. (JFIF: 0x4a 0x46 0x49 0x46)
*PGM comes in two formats as does TIFF. While the tiff differences are listed, pgm differs in that plain pgm stores one image and pgm2 (both .pmg) stores more than one. Both are pure black and white, binary, photos.
Resources:
JPG: http://en.wikipedia.org/wiki/JPEG
PNG: http://en.wikipedia.org/wiki/Portable_Network_Graphic
GIF: http://en.wikipedia.org/wiki/Graphics_Interchange_Format | http://www.onicos.com/staff/iz/formats/gif.html
TIFF: http://www.fileformat.info/format/tiff/egff.htm
One thought on “Ending and Starting Bytes for Images”