(636) 578-3604Monday - Friday 8am-5pm

IMAGE METADATA (EXIF)

A picture is worth a 1000 words, but your metadata is priceless - JPG Image Metadata

A look at your smartphone pictures: revealing more personal info than most people realize.

When you take a picture with your smartphone/camera and put it on the web, do you realize that you are providing a lot of personal information that anyone can see? Most likely the following info (metadata) is in your JPG picture:

The exact location where the picture was taken

Almost all new phone and cameras have a GPS sensor in them. If you have enabled geo-tagging in your photos, the precise location that the picture was taken at is embedded in your image. This includes latitude, longitude, and altitude.

The exact date and time the picture was taken

The camera sets a date/time stamps in the picture when the picture was taken and when it was digitized.

The type of camera/phone which took the picture

My smart phone sets the Make as “HTC” and the Model as “Desire HD”.  There even may be a serial number in there to uniquely identify your camera.

This type of information can reveal where your home is or where you were at on a particular day.  Big privacy concern!

Bottom line

As a general rule of thumb, you should remove personal information from image files before you add pictures to to an on-line site.  There are many tools which allow you to do this.

Anatomy of a JPG image

Next, I’ll do an in-depth examination the metadata contained in a JPG image.  I’ll cover JPG images that use the Exchangeable Image File or EXIF format which is the most common image format used by digital cameras. Most smartphones these days have a GPS sensor and camera which takes JPEG (Joint Photographics Experts Group) pictures.   Note: the JPG and JPEG are both commonly used to refer to JPEG images. The format of the images is governed by the EXIF (Exchangeable Image File) format for digital still cameras.  Let’s look at EXIF version 2.2. The main parts of a JPG image are:
  • Primary image = main picture
  • Thumbnail = smaller version of the primary image
  • Image Metadata
The Image metadata is what we are going to look at in depth here.  Up to 64 Kbytes of Image Metadata can be stored in a JPEG (JPG) image (that’s a lot of memory). The Metadata is stored in the Tag Image File Format (TIFFTM) governed by the TIFF 6.0 Specification.
The TIFF Header starts the Image.  The TIFF header is 8 bytes and contains the File byte order, and offset to the 0thIFD (Primary Image IFD) TIFF Header
  • Byte Order (2 bytes) – either Little Endian: 0x4949 = “ll” or Big Endian: 0x4d4d = “MM”
  • 42 (2 bytes) = 0x2a (just a constant)
  • Offset of 0th IFD (4 bytes) – if the 0th IFD follows the TIF Header, the value 0x00000008 is used (8 byte offset)

Metadata is located within IFDs (Image File Directories).  An IFD consists of a 2 byte count which indicates the number of fields or tags that it contains, a set of tags (each of which is 12 bytes) and a 4 byte offset to the next IFD. IFDs in an image:
  • Primary Image IFD (0th IFD) = IFD containing tags about the primary image.  Contains pointers to the other IFDs.
  • Thumbnail IFD (1st IFD) contains tags about thumbnail image.
  • EXIF IFD= IFD containing tags for recording EXIF-specific attributes
  • GPS IFD= Contains any GPS data associated with the image.
  • Interoperability IFD = has interoperability tag in it

Each piece or field of metadata recorded within an IFD is called a Tag.  Each Tag is 12 bytes with an ID (2 bytes), data type (2 bytes), length (4 bytes), and value/value offset (4 bytes). A Tag has:
  • ID = identifies the what type of tag it is according to specification
  • Type = type of tag (1=BYTE, 2=ASCI, 3=SHORT, 4=LONG, 5=RATIONAL, 7=UNDEFINED (can take on any value), 9=SLONG,10=SRATIONAL)
  • Count = Number of values (not number of bytes)
  • Value/Value Offset = if the value fits in 4 bytes, then it is recorded in this area.  Otherwise, this property gives the offset to the starting location for the value.

Ok, here’s an example to see what we’re talking about.  You can manually go through the a hex dump of the image file (Here’s how to do a hex dump using C#) and determine the TIFF Header, IFDs, and Tags. Hex dump of JPG image: imag0065.jpg (only start shown)

00: ff d8 ff e1 02 62 45 78 69 66 00 00 4d 4d 00 2a
10: 00 00 00 08 00 08 01 0f 00 02 00 00 00 04 48 54
20: 43 00 01 10 00 02 00 00 00 0a 00 00 00 6e 01 1a
30: 00 05 00 00 00 01 00 00 00 78 01 1b 00 05 00 00
40: 00 01 00 00 00 80 01 28 00 03 00 00 00 01 00 02
50: 00 00 02 13 00 03 00 00 00 01 00 01 00 00 87 69
60: 00 04 00 00 00 01 00 00 00 88 88 25 00 04 00 00
70: 00 01 00 00 01 60 00 00 00 00 44 65 73 69 72 65
80: 20 48 44 00 00 00 00 48 00 00 00 01 00 00 00 48
90: 00 00 00 01 00 0b 88 27 00 03 00 00 00 01 00 88
a0: 00 00 90 00 00 07 00 00 00 04 30 32 32 30 90 03
b0: 00 02 00 00 00 14 00 00 01 12 90 04 00 02 00 00
c0: 00 14 00 00 01 26 91 01 00 07 00 00 00 04 01 02
d0: 03 00 92 0a 00 05 00 00 00 01 00 00 01 3a a0 00
e0: 00 07 00 00 00 04 30 31 30 30 a0 01 00 03 00 00
f0: 00 01 00 01 00 00 a0 02 00 04 00 00 00 01 00 00

Starts with File Header

00: ff d8 ff e1 02 62 45 78 69 66 00 00
ff d8: SOI (start of image) – JPEG files always start with this

TIFF Image File Header –8 bytes
0C: 4d 4d 00 2a 00 00 00 08
Bytes 0-1 = 4d 4d = “MM” Big Endian Order”
Bytes 2-3 = 00 2a = 42 = Id as TIFF File
Bytes 4-7 = 8 = offset in bytes of 0th IFD (starts at 0x10)

0th IFD (1st IFD) (2 bytes long)
14:  00 08
Bytes 0-1 = Number of entries = 8

1st Tag in 0th IFD (12 bytes long)
16: 01 0f 00 02 00 00 00 04 48 54 43 00
Bytes 0-1 (Tag ID) = 01 0f = 271 = Make
Bytes 2-3 (Tag Type) = 00 02 = 2 = Ascii
Bytes 4-7 (Count) = 00 00 00 04 = 4 = 4 Characters
Bytes 8-11 (Value) = 48 54 43 00 = “HTC\0” – tag value is here (not offset)

2nd Tag in 0th IFD (12 bytes long)
22: 01 10 00 02 00 00 00 0a 00 00 00 6e
Bytes 0-1 (Tag ID) = 01 10 = 272 = Model
Bytes 2-3 (Tag Type) = 00 02 = 2 = Ascii
Bytes 4-7 (Count) = 00 00 00 0a = 10 = 10 Characters
Bytes 8-11 (Value) = 00 00 00 6e = Offset = 6e = 110 Bytes
– This means the value is an Ascii string (length 10 starting at 122 Bytes = 0x78)
78: 44 65 73 69 72 65 29 48 44 00 = “Desire HD\0”

And so on…


 
Close Menu