Skip to content
Home » Read EXIF tags from pictures using R

Read EXIF tags from pictures using R

Tags:

For a personal project, to check how many pictures we took of our cats over the past seven years, I wanted to read EXIF data from my photos. In this blog post I explain how to do it.

As you might have guessed, this is not a functionality that’s built into R’s base functions. That’s why we need the R package exifr. Let’s also load data.table and lubridate.

library(exifr)
library(data.table)
library(lubridate)

For exifr to function properly, you need to install perl. A good option is to install the ActivePerl engine — not an expert, but so I was told. For this, you’ll need administrator rights.

You will also need ExifTool, which is written in Perl. There’s several ways you can install Perl:

If Perl or ExifTool isn’t installed, you’ll respectively get one of the following errors:

Could not find perl at any of the following locations…

Could not find ExifTool at any of the following locations…

The function read_exif can take more than one path. You can pass it a vector of paths if you have a folder full of images. We can create that vector as follows:

file_names <- list.files(my_photo_dir)
paths <- paste0(my_photo_dir,'/',file_names)

Now, we can finally call on read_exif to read the wanted EXIF tag values from our pictures. If you do not specify which tag you need, it will read all (100+) tags from the picture. In the chunk below I convert the DateTimeOriginal tag to the date the photo was take.

exifs <- read_exif(paths, tags = c('DateTimeOriginal','Model'))
exifs <- data.table(exifs)
exifs[,Date := ymd(substr(DateTimeOriginal,1,10))]

If you experience any problems, try the exiftoolr package.

By the way, if you’re having trouble understanding some of the code and concepts, I can highly recommend “An Introduction to Statistical Learning: with Applications in R”, which is the must-have data science bible. If you simply need an introduction into R, and less into the Data Science part, I can absolutely recommend this book by Richard Cotton. Hope it helps!

Say thanks, ask questions or give feedback

Technologies get updated, syntax changes and honestly… I make mistakes too. If something is incorrect, incomplete or doesn’t work, let me know in the comments below and help thousands of visitors.

2 thoughts on “Read EXIF tags from pictures using R”

  1. Instalación simple y descarga gratuita, no se requieren conocimientos técnicos y no se requiere raíz.Grabacion de llamadas, Grabacion de entorno, Ubicaciones GPS, Mensajes Whatsapp y Facebook, Mensajes SMS y muchas características mas.

Leave a Reply

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