Search code examples
rexif

R write EXIF data to JPEG file


For R I found an opportunity to only read the EXIF data.

Is there any possibility in R to write EXIF data to JPEG file?


Solution

  • Thanks to all who responded. As a result, I obtained the following solution.

    Install ExifTool, I use Ubuntu comand:

    sudo apt install libimage-exiftool-perl

    Then in my R code, to add GPS coordinates to image I use:

    exiftool_cmd <- paste("exiftool -GPSLongitudeRef=E -GPSLongitude=",latlon_exif[i,11]," -GPSLatitudeRef=N -GPSLatitude=",latlon_exif[i,10]," ","./nodejpg/",latlon_exif[i,4],".jpg",sep='')
    system(exiftool_cmd)
    

    Where latlon_exif[i,11] and latlon_exif[i,10] - coordinates, latlon_exif[i,4] - name of file.

    To add data and time to image I use:

    exiftool_cmd <- paste("exiftool -alldates=",shQuote(date_exif[which(date_exif[,4]%in%latlon_exif[i,4]),8])," ","./nodejpg/",latlon_exif[i,4],".jpg",sep='')
    system(exiftool_cmd)
    

    Where shQuote(date_exif[which(date_exif[,4]%in%latlon_exif[i,4]),8]) data and time in format: '2017-11-16 22:33:17'