paint-brush
Obtaining Data From Images Using Exif: How To Automate The Processby@anthony-morris
1,063 reads
1,063 reads

Obtaining Data From Images Using Exif: How To Automate The Process

by anthony morrisMay 1st, 2021
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Exif is a standard that specifies the formats for images, sound, and ancillary tags used by digital cameras. It is not used in JPEG 2000 or GIF. To access this data, you’ll need to interpret the image itself. To automate this Exif extraction, you can easily use Linx to work through each image with a small command-line utility called Exiftool.org. The solution in Linx Designer (free) is called PullExifData.

Coin Mentioned

Mention Thumbnail
featured image - Obtaining Data From Images Using Exif: How To Automate The Process
anthony morris HackerNoon profile picture

What is Exif Data?

Exchangeable image file format (officially Exif , according to JEIDA/JEITA/CIPA specifications) is a standard that specifies the formats for imagessound, 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)[2] 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).[3] It is not used in JPEG 2000 or GIF.

How to pull Exif data

In order to access this data, you’ll need to interpret the image itself. To automate this Exif extraction, you can easily use Linx to work through each image with a small command-line utility called Exiftool.

Steps to recreate

  • First, download and install the Windows Executable from Exiftool.org.
  • Extract Exiftool and rename the exe file to “exiftool.exe”
  • Start a new solution in Linx Designer (free)
  • Add a Setting for the full path to the “exiftool.exe” file:

Creating the PulllExifData Function

1. Add a new Function to your solution called PullExifData (this will be the re-usable function to extract Exif data into an easily accessable List of Name and values.)

2. Create a new Type called “NameAndValue” with 2 string properties called “Name” and “Value”:

3. Back, on your PullExifData Function, add a String Parameter field for this function for “ImageFullPath”

4. Add a Result field for the PullExifData function called “ListOfEXIFData” which is a List < NameAndValue > (A list of the Type we created a couple of points above.)

5. The full flow of the PullExifData function will look like this:

6. FullCMD is a String, with a value of the Command that needs to be executed: =$.Settings.ExifToolPath + " " + $.Parameters.ImageFullPath

7. CommandLine runs the String above and provides an Output as text.

8. ListOfLines takes the String from the CommandLine and splits it into each line as a String, by cutting off each line at the NewLine point ($.System.NewLine): =CommandLine.Output.Split($.System.NewLine)

9. ListOfNamesAndValue is just an empty list, of the Type we created earlier called “NameAndValue”

10. In the “ForEach” we will loop through the ListOfLines

11. For each Line of the ListOfLines, we first Split the value again into a small String List called NameAndValueInList. Each Line contains a “Name : Value” pair, separated by a colon (:). =ForEach.Loop.Split(":")

12. Because some lines from the ListOfLines may be empty or not contain a “Name : Value” pair, we do a “ValueExists” if-else check. The condition we are checking for basically check if the Split(":") was successful in creating 2 values (and as such a “:” was present and a Name and Value was extracted.

13. Now we can finally add the extracted Name and Value to the ListOfNamesAndValues list with AddToList:

14. At the end of the function, SetValueResult saves our populated list as the Result of the Function:

This gives us everything we need to extract Exif data from a photo, and we can use this function in any other Function to get specific data. For example, if I want to extract Exif Data called “User Comment” and save it to a Database:

Voila! You're done. Some example data from a photo:

Want the Solution?

Download the completed solution for Linx 5.20 here: EXIFExtractor.lsoz (8.7 KB)