Exiv2 vs. ExifTool
For our Placeholder Thumbnail Feature, we need to write the extracted metadata from the original image to its thumbnail. Furthermore we need a reliable metadata "backend" that acts as a fallback when our internal pure-python metadata libraries fail (e.g. Camera RAW files). This article evaluates two well-known tools, exiv2 and exiftool for their "picurl suitability".
Exiv2
- Exiv2 Website
- developed since 2004
- written in C, no external dependencies
Features:
Quoting from the exiv2-Website:
- print the Exif metadata of JPEG, TIFF and several RAW image formats as summary info, interpreted values, or the plain data for each tag
- print IPTC and XMP metadata
- print, set and delete the JPEG comment of JPEG images
- set, add and delete Exif, IPTC and XMP metadata of JPEG images
- adjust the Exif timestamp (that's how it all started...)
- rename Exif image files according to the Exif timestamp
- extract, insert and delete Exif, IPTC and XMP metadata and JPEG comments
- extract, insert and delete the thumbnail image embedded in the Exif metadata
- fix the Exif ISO setting of picture taken with Nikon cameras
Exiftool
- Exiftool Website
- developed since 2003
- written in Perl, self contained .exe/.img distributions for Windows/Mac OS (no Perl interpreter needed).
Features:
Quoting from the exiftool-Website:
- Powerful, fast, flexible and customizable
- Supports a large number of different file formats
- Reads EXIF, GPS, IPTC, XMP, JFIF, MakerNotes, GeoTIFF, ICC Profile, Photoshop IRB, FlashPix, AFCP, ID3 and more...
- Writes EXIF, GPS, IPTC, XMP, JFIF, MakerNotes, ICC Profile, Photoshop IRB, AFCP and more...
- Reads and writes maker notes of many digital cameras
- Shifts date/time values to fix timestamps in images
- Renames files and organizes in directories (by date or by any other meta information)
- Extracts thumbnail images, preview images, and large JPEG images from RAW files
- Copies meta information between files (even different-format files)
- Deletes meta information individually, in groups, or altogether
- Sets the file modification date from EXIF information
- Supports alternate languages in XMP and MIE information
- Processes entire directory trees
- Creates text output file for each image file
- Automatically backs up original image when writing
- Organizes output into groups
- Conditionally processes files based on value of any meta information
- Ability to add user-defined tags
- Recognizes thousands of different tags
- Tested with images from thousands of different camera models
- Advanced verbose and HTML-based hex dump outputs
The Test
I tested two key abilities of exiv2 and exiftool: the JPEG thumbnail extraction for a bunch of photos and writing IPTC tags to the generated thumbnails. My testsuite consisted of 157 JPEGs with embeded EXIF Metadata and Thumbnails, each at 6 Megapixel, Total size of the directory: 227 MB.
In the test I invoked the exiv2/exiftool binaries from a python script (subprocess), which also measured the time for the task. For the thumbnail extraction, the globbing options of the tools were used (i.e. exiv2 -et *.jpg vs exiftool -b -ThumbnailImage *.jpg -w _thumb-exiftool.jpg). The IPTC write test was conducted by invoking one exiv2/exiftool instance for each photo (exiv2 -M "add Iptc.Application2.City Wien" PHOTO_001.jpg vs. exiftool -iptc:city=Wien PHOTO_001.jpg).
Here are the amazing results:
exiv2 Thumbnail extraction execution took: 0.639 Seconds exiv2 IPTC Write test execution took: 2.630 Seconds Exiftool Thumbnail extraction execution took: 4.497 Seconds Exiftool IPTC Write test extraction execution took: 144.522 Seconds
which means that Exiftool is approx. 54 times slower than exiv2 when it comes to writing metadata and 7 times slower for the thumbnail extraction.
exiv2 Pros:
- BLAZING FAST , also when writing Metadata Tags to images
- intuitive tag syntax
- pyexiv2 binding (still experimental)
- intuitive output configuration
exiv2 Cons:
- doesn't work with Photoshop Files
- inflexible Thumbnail Extraction (can only be extracted to the same directory with a -thumb suffix -> problem on read-only media), pyexiv2 provides a convenience method pyexiv2.Image.dumpThumbnailToFile(path) to set a path.
- limited support of MakerNotes/RAW formats (but steadily growing)
- doesn't autobackup image files when writing metadata to them (not necessary for our purpose)
- no IPTC/EXIF <-> XMP conversion (but planned by the developers)
- currently unable to write multi-line JPEG Comments, returns only last line of multiline JPEG comments when using Irfanview as tag creator . Need this functionality for our picurl directives.
- Installation on MacOS X might be a challenge (exiv2 is distributed as Fink Package)
exiftool Pros:
- extracts metadata from nearly any multimedia file format (not just images)
- comprehensive support of raw files
- comprehensive support of metadata standards (EXIF, proprietary Makernotes,...)
- copy meta information between files
- tag conversion functions
exiftool Cons:
- SLOOOOOOOOOW when writing metadata to files
- no Python binding, can only be invoked via shell
- problems with piping on win32.
Conclusion
For our task (writing metadata of original images to the extracted thumbnails), exiv2 is definitely better suited than exiftool.
