exif icon indicating copy to clipboard operation
exif copied to clipboard

Check for existence of EXIF data?

Open jaypinho opened this issue 2 years ago • 1 comments

Hi there,

Great gem - thanks for all the hard work.

Was wondering: unless I missed it, I didn't see a way to check a file or string for the presence of EXIF data before then accessing the EXIF data itself.

So if I have an image file where I don't know if EXIF data exists or not, it seems like the best way to verify is to check if the Exif::NotReadable error is returned. Is that correct / expected?

jaypinho avatar Aug 29 '22 09:08 jaypinho

Hi @jaypinho, thanks for reaching :)

So if I have an image file where I don't know if EXIF data exists or not, it seems like the best way to verify is to check if the Exif::NotReadable error is returned. Is that correct / expected?

Yes, it is expected.

This gem is ported from libexif library and looks like EXIF_LOG_CODE_CORRUPT_DATA cannot distinguish between EXIF absence and corruption, see https://github.com/libexif/libexif/blob/f4a882b15d41da893a7759cfa014acf6c9f87821/libexif/exif-data.c. Thus there is no straightforward way to check if the existence of EXIF data.

tonytonyjan avatar Sep 05 '22 02:09 tonytonyjan