The guide
A JPEG file holds a second file inside it, and it can say where you stood
Camera settings, a thumbnail and sometimes a latitude and longitude ride along with every photo, stored in a tiny file system with its own byte order and its own pointers.
- II or MM two letters that set the byte order
- 374 bytes Exif block of the made-up example photo
- 1280 directory count when a big-endian file is read as little
- -79.982222 79 58 56 W as a signed decimal degree
- 65,533 bytes the most one Exif segment can hold
Read the full guide Fold the guide
Open a photograph in a hex editor and the picture is the least interesting part. Near the very top, before any pixel data, sits a block of text and numbers: the make of the camera, the time the shutter fired, the exposure, and on many phones the place where the person was standing. That block is called Exif, and it is a file inside the file.
Most people never see it. It is not shown when you view the photo, and it is not removed when you send the photo to a friend. Whether that is a convenience or a leak depends on who receives the file and what the block says.
A file inside a file
A JPEG is a sequence of segments. Each one starts with the byte FF and a marker code, then a two-byte length. The JPEG File Interchange Format page notes that this length is a big-endian number that counts its own two bytes, so a reader that forgets to include them lands two bytes past the next marker. Exif uses the application segment called APP1, marker FFE1, and puts a complete TIFF file inside it.
That choice has a ceiling. The length is sixteen bits, so one segment can hold at most 65,533 bytes after the length field, and the Exif page says the metadata of a JPEG is held to about 64 kilobytes for that reason. The Library of Congress format description adds that compressed Exif files are baseline JPEG with the metadata in APP1 and APP2 segments, while uncompressed ones are TIFF.
A reader finds the block by walking the segments until it meets one whose payload begins with the letters Exif and two zero bytes. The Exif page notes an overlap with IPTC and XMP descriptions, which can also be embedded in a JPEG file, so another APP1 segment may carry XMP, and a careless reader that only looks for the word Exif somewhere inside can mistake one for the other.
Two letters decide how every number reads
The first two bytes of the TIFF block are either II or MM. According to the TIFF page, II means little endian, the Intel convention, and MM means big endian, the Motorola convention. The next two bytes hold the number 42, in whichever order was just declared. Then comes the offset of the first directory.
The Endianness page explains the idea: the order in which the bytes of a multi-byte number are stored. The number 5 as a sixteen-bit value is 05 00 in a little-endian file and 00 05 in a big-endian one. Read the big-endian bytes the wrong way and the same two bytes say 1280.
That is not a thought experiment. The example photo header on this page exists in both orders. Its Exif block is 374 bytes either way, and the first eight bytes are 49 49 2A 00 08 00 00 00 in one and 4D 4D 00 2A 00 00 00 08 in the other. A reader that assumes big endian handles the second file and falls over on the first.
A directory of twelve-byte entries
A directory is a count, a list of entries, and a pointer to the next directory. Each entry is twelve bytes: a tag number, a type, a count of values, and a four-byte field. In the example, the first directory has five entries and starts at offset 8. It occupies 2 bytes for the count, 5 times 12 for the entries and 4 for the next pointer, 66 bytes in all, so the Exif directory that follows starts at offset 74.
The four-byte field is the clever part. If the value is small enough to fit, it sits right there. A single orientation number is two bytes long, so it lives in the entry. A camera name of nine characters does not fit, so the field holds an offset instead, and the name sits further along the block. The rule is the type size times the count: four bytes or fewer stay in the entry, anything larger is pointed to.
Some entries are pointers to whole directories. The Exif page names three: tag 0x8769 leads to the Exif directory, 0x8825 to the GPS directory, and 0xA005, found inside the Exif directory, to an interoperability directory. A reader that never follows 0x8769 will find the make and model and then report that the photo has no pixel size, because the size lives behind the pointer.
Values come in a dozen types, from single bytes to 32-bit numbers to a rational, which is a pair of integers, a numerator and a denominator. The Rational number page explains why that is a good choice for a camera: an exposure of one two-hundred-fiftieth of a second is stored exactly as 1 over 250, with no rounding.
What the tags say
The Exif page keeps a version table. Version 2.0, dated November 1997, added GPS and compressed thumbnails, so a file from an earlier camera cannot carry a GPS directory at all, and a file from a later one may carry many tags that this reader shows only by their number.
The summary card reads the same few tags in any photo. The shutter speed page and the F-number page describe the exposure time and the aperture, and the Film speed page covers the ISO number. In the example, the exposure is 1/250 of a second, or 0.004, the aperture is f/2.8 and the sensitivity is ISO 400.
The orientation tag takes a value from 1 to 8. Value 1 is a picture that needs no change, 6 means rotated 90 degrees clockwise, and the other values mirror or turn it in the other ways. The example uses 6, which is the usual result of holding a camera upright.
Where you were standing
The location tags are the part worth a second look. The Exif page says that many cameras and mobile phones have a built-in GPS receiver that stores the location in the Exif header at the moment a picture is taken. The Geotagging page notes that the automatic embedding of geotags in smartphone pictures is often ignored by the people who take them, so they are unaware that photos they publish carry coordinates.
The coordinates are stored as three rationals for degrees, minutes and seconds, plus a letter for the hemisphere. The Geographic coordinate conversion page shows the same point two ways: 40 degrees 26 minutes 46 seconds north and 79 degrees 58 minutes 56 seconds west, or in decimal degrees about plus 40.446 and minus 79.982.
Here is the arithmetic. Degrees plus minutes over 60 plus seconds over 3600 gives 40.446111 for the latitude and 79.982222 for the longitude. The letter W makes the longitude negative: minus 79.982222. A reader that drops the sign puts the photo about 160 degrees of longitude away from where it was taken, on the wrong side of the planet.
The Exif page also records an older leak of a different kind. A cropped photograph can carry a thumbnail of the uncropped picture, which is how an image shared in June 2003 ended up showing more than its owner intended.
Reading it without sending it anywhere
A page that reads a photo does not need a server. A file chosen in the browser can be cut with Blob slice and read with the arrayBuffer method, and the MDN pages for DataView and TextDecoder cover the rest: DataView reads numbers in a stated byte order, and TextDecoder turns the text bytes into a string. Because the Exif block comes before the picture data, the first megabyte is enough, and the Web Workers API lets that work run off the main thread.
The method has limits. It reads JPEG and nothing else, so a PNG, a WebP or a HEIC file is refused with a plain message. It does not read maker notes beyond their size, because those are a manufacturer’s private format. It does not edit or remove anything. A tag it cannot name is shown by its number with the word unknown, and a value that runs past the end of the block is reported as truncated at that tag.
If the location card shows a pair of coordinates for a photo you were about to post, that is the moment to strip the metadata first, or to choose a different picture.
Sources
Every source consulted for this guide. Links checked November 15, 2026.
- Exif (Exchangeable image file format) Wikipedia (CC BY-SA)
- TIFF (Tag Image File Format) Wikipedia (CC BY-SA)
- JPEG (image compression standard) Wikipedia (CC BY-SA)
- JPEG File Interchange Format Wikipedia (CC BY-SA)
- Endianness Wikipedia (CC BY-SA)
- Geotagging Wikipedia (CC BY-SA)
- Geographic coordinate conversion Wikipedia (CC BY-SA)
- F-number Wikipedia (CC BY-SA)
- Shutter speed Wikipedia (CC BY-SA)
- Film speed Wikipedia (CC BY-SA)
- Rational number Wikipedia (CC BY-SA)
- Exif Exchangeable Image File Format, Version 2.2 Library of Congress (US government)
- DataView MDN Web Docs (CC BY-SA)
- Blob: slice() method MDN Web Docs (CC BY-SA)
- Blob: arrayBuffer() method MDN Web Docs (CC BY-SA)
- TextDecoder MDN Web Docs (CC BY-SA)
- Web Workers API MDN Web Docs (CC BY-SA)
- ExifTags module Pillow documentation (MIT-CMU licence)