About the Support ExifInterface

Version 25.1.0 of the Android Support library has debuted a new com.android.support:exifinterface artifact, which offers a standalone implementation of ExifInterface, a Java class for reading the EXIF tags from JPEG and raw files.

If that class name sounds familiar, that is because:

  • in May, I suggested moving ExifInterface into Android Support, to provide InputStream as a data source, to better work with content Uri values

  • in September, I suggested moving ExifInterface into Android Support, to give us an implementation that was free of the security bug that Tim Strazzere uncovered

The new ExifInterface is not showing up in the online Android developer documentation. Also, there are no JavaDocs in the Android Support Repository (the JavaDocs JAR is effectively empty). Hopefully, this is a temporary hiccup.

Based on eyeballing the source to android.support.media.ExifInterface, it seems like they matched the API of the Android 7.0 ExifInterface implementation.

This solves two problems:

  1. We now have an ExifInterface constructor that takes an InputStream

  2. This implementation is pure Java, and so it avoids the buggy JHEAD implementation that was the source of the security flaw

Note though that this class — and its SDK counterpart — offers a limited API compared with ExifInterface code elsewhere in the AOSP. In particular:

  • You cannot modify the thumbnail image

  • You cannot save modified EXIF tags, thumbnails, etc. to a different JPEG file than the one that you started with

Hence, you may find yourself still needing to use a separate EXIF parser, just to get needed functionality.

That being said, though, the ExifInterface in the the Android Support library is a welcome addition, and I am very grateful to the engineers who took the time to create it!

Find out about new posts on the CommonsBlog via the Atom feed, or follow @CommonsWare on Twitter!