How many ways are there to put an extra “thumbnail” or “preview” image inside a JPEG (.jpg) image file?
This isn’t just trivia. One problem with thumbnails is the possibility that they might be neither updated nor deleted when the main image is edited. If you’re not careful, your edited JPEG file could contain a small copy of the original image, which might be private or sensitive. So, it’s nice to know where such images could be hiding.
Note that most of these formats limit thumbnails to around 64KB in size, due to technical limitations of the JPEG format.
Here are the ways I know of to put a thumbnail in a JPEG file:
Exif is a standard that defines a blob of metadata that can be found in many JPEG files, especially those created by digital cameras. It has a standard way to store a thumbnail, usually JPEG-compressed. Uncompressed thumbnails are also possible, but rare.
While it’s not a shining example of how to design a format, I’d say that, all things considered, a JPEG-compressed Exif thumbnail is the best way to put a thumbnail in a JPEG file.
A lot of JPEG files contain Photoshop-style metadata, which often includes a JPEG-compressed thumbnail. Uncompressed thumbnails are possible, but rare. Many JPEG files have both an Exif thumbnail and a Photoshop thumbnail, and these thumbnails are usually byte-for-byte identical.
Multi-Picture Format, or “MP”, or “MPF”, or “MPO”, is a multi-image JPEG extension. I don’t think it’s very well known, but it’s not terribly rare. It can be used for thumbnail images, among other things. It includes a segment inside the normal JPEG data, which points to the actual extra image(s), which are appended to the end of the file. Unfortunately, a lot of JPEG editing software will strip off the extra image(s), leaving a now-invalid MP segment that points to nowhere.
MP thumbnails are always JPEG-compressed, and are not subject to the 64KB limit.
Exif FPXR (FlashPix)
FPXR segments are a weird appendage to the usual Exif metadata, and they use a completely different format. I don’t really understand the point of them (it has something to do with the obsolete FlashPix image format), but unlike the main Exif data, FPXR data elements do not have a 64KB size limit. I assume that’s why they’re sometimes used as a place to put thumbnail images.
I don’t think FPXR has a standard thumbnail format, but I’ve seen two different custom formats:
- A stream named “/<U+0005>Screen Nail_bd0100609719a180”, containing a Microsoft OLE Property List, in which one property is a blob containing a JPEG image.
- A stream named “/FUJIFILM/Preview”, which contains a JPEG image.
The Exif “MakerNote” element is a way to store custom data within Exif metadata. While not necessarily bad in principle, MakerNotes turned into a disaster, because too many implementers, in addition to not documenting their MakerNote format, did not even make it identifiable and relocatable. So, a lot of MakerNotes are a mystery blob of bytes that becomes corrupted if the file is ever edited. But I digress.
Since Exif already has a standard thumbnail format, there’s no good reason to put a thumbnail inside a MakerNote. So, nobody does.
Ha ha, no. Many MakerNote thumbnail formats exist, though admittedly most of them don’t appear to be very commonly used.
I scanned a bunch of MakerNotes, looking for embedded JPEG files, which I assumed would be thumbnail images. My limited experience suggests that the most common MakerNote thumbnail format is Nikon’s “PreviewIFD” format. I also found some apparent JPEG thumbnails in Ricoh, Pentax (“AOC”), and Casio (“QVC”) MakerNotes. I would have overlooked any MakerNote thumbnails that aren’t JPEG-compressed, so I don’t know how common they are.
JFIF is a standard that defines the most common “flavor” of JPEG. It originally only supported an uncompressed thumbnail image. JPEGs with such a thumbnail image are very rare. I found a file that has one, but the thumbnail seems to be malformed.
JFIF – JFXX
JFIF v1.02 introduced an optional “JFXX” segment that contains a JPEG-compressed thumbnail image. I have seen this used in the wild, but it’s very rare. I don’t know why it’s so rare. It seems like a good thing, and it’s much easier to support than Exif.
SPIFF, much like JFIF, is a standard that defines a “flavor” of JPEG. (It also defines some non-JPEG image formats, but that’s not important here.) It has a standard thumbnail format, which can be JPEG-compressed, or uncompressed. SPIFF is not popular, and I have never seen it used. I mean I’ve never seen SPIFF used, with or without a thumbnail.
Nevertheless, I think it’s fair to say that SPIFF is the most-officially-standard-approved way to put a thumbnail in a JPEG file. JFIF began as kind of a rogue format (it only became an ITU standard around 2011, after 20 years of use), while SPIFF was the format sanctioned by the people in charge of JPEG.
The above is not intended or expected to be a complete list of JPEG thumbnail formats. I’m sure I’ve missed some, and anyone can invent a new JPEG thumbnail format at any time.