3

I have an image processing app which needs to remember which photos were already processed. The solution I came up with was to store a given String ("abc-"), into the EXIF MAKE tag. So, in order to filter the photos, my app needs to read the EXIF MAKE attribute to see if it contains my String ("abc-"). I have tested it with the following code and its execution took around 15 seconds on a friend's phone with Android 5.1.1 CyanogenMod and 1000 photos, which is a very poor time.

public boolean isAlreadyProcessed(File imageFile) {
    android.media.ExifInterface exifInterface = new ExifInterface(imageFile.getAbsolutePath());
    String attribute = exifInterface.getAttribute(ExifInterface.TAG_MAKE);

    return attribute.contains("abc-");
}

Other solution I thought about was to store the processed images filenames into a SQLite database. This would be a faster option, but it has the problem that if a user copys his photos to a new device, my app wouldn't remember which photos were already processed, so I would need to backup my database to the cloud and restore it on the new device.

So, is there a more efficient way to read EXIF image metadata? If not, is there a better way to accomplish this than the second way I mentioned (to store the images names in a database)?

Thank you

Ernestina Juan
  • 957
  • 1
  • 9
  • 24
  • 1
    "its execution took around 15 seconds on a friend's phone with Android 5.1.1 CyanogenMod and 1000 photos, which is a very poor time" -- really? 15 milliseconds per photo is "a very poor time"? I am stunned that you are able to get it going that quickly. "so I would need to backup my database to the cloud and restore it on the new device" -- or do a one-time scan of the photos using your existing algorithm. – CommonsWare Jun 19 '15 at 15:41
  • Yes, that's fine, will try it. Thank you! – Ernestina Juan Jun 19 '15 at 16:12
  • Oh, excuse me. The execution took 15 seconds with 12 photos, not 1000 – Ernestina Juan Jun 19 '15 at 16:34
  • That's a bit of a difference. I don't know enough about JPEG files and EXIF to have a sense of whether `ExifInterface` is abnormally slow. Photos are decent-sized files, and flash storage tends to be slow, so it's not going to be super-speedy. You could look at alternative EXIF implementations, such as [this one I culled from the AOSP Mms app](https://github.com/commonsguy/cwac-camera/tree/master/camera/src/com/android/mms/exif). – CommonsWare Jun 19 '15 at 16:38
  • Thank yout, I'm going to try it, and if it doesn't work I would go for the cloud save – Ernestina Juan Jun 19 '15 at 22:15

0 Answers0