How to Read EXIF data with ImageMagick plugin




GeeXLab - ImageMagick demo showing EXIF information



The EXIF data is a set of information about an image. Here is a more formal definition cribbed from wikipedia:

Exchangeable image file format (officially Exif, according to JEIDA/JEITA/CIPA specifications) is a standard that specifies the formats for images, sound, and ancillary tags used by digital cameras (including smartphones), scanners and other systems handling image and sound files recorded by digital cameras. The specification uses the following existing file formats with the addition of specific metadata tags: JPEG discrete cosine transform (DCT) for compressed image files, TIFF Rev. 6.0 (RGB or YCbCr) for uncompressed image files, and RIFF WAV for audio files (Linear PCM or ITU-T G.711 μ-Law PCM for uncompressed audio data, and IMA-ADPCM for compressed audio data). It is not used in JPEG 2000 or GIF.

Cool…

In practice, the EXIF data associated with an image contains values like size of the image, aperture value, exposure time, focal length or F-number.

You can read some of the EXIF data with GeeXLab using two functions of the ImageMagick plugin exposed via the gh_imagemagick library:

file_exif_get_num_properties()
file_exif_get_property()

These functions are really easy to use. First, get the number of EXIF fields (or properties) available with file_exif_get_num_properties and then loop through the fields using file_exif_get_property.

Okay, I feel you need an example…

 
local num_props = gh_imagemagick.file_exif_get_num_properties(filename)
for i=1, num_props do
  local prop_name, prop_value = gh_imagemagick.file_exif_get_property(filename, i-1)
  print(prop_name .. " => " .. prop_value)
end

As you can see, enumerating the EXIF data only requires the filename. No need to load the image and create a texture. Combined to LuaFileSystem (you can use LuaFileSystem in GeeXLab with the built-in lfs library: lfs.dir()…), you can browse your photos folders and store EXIF data in a SQLite3 database…

 

The DEMO

The demo is shipped with GeeXLab in the {GeeXLab folder}/apps/magickview/.

A stupid bug in GeeXLab 0.25.0.0 prevents from using the file_exif_get_property() function. So you need GeeXLab 0.25.1.0 to play with the EXIF demo.

You can download GeeXLab from THIS PAGE.

You can also download the demo directly from THIS LINK.

For any comment or feedback, a thread is available HERE (EN) or HERE (FR).

On Windows platform, launch the MagickView demo, and drag/drop an image into MagickView. If the image is supported by ImageMagick, you should see something like this:


GeeXLab - ImageMagick demo showing EXIF information





Leave a Comment

Your email address will not be published. Required fields are marked *