Search code examples
rexiftool

Copy all EXIF information from one jpg to another jpg in R


I read a jpg image into R as well as all of its EXIF metadata. Then I do some manipulation to the image and write the output as jpg. How could I copy all EXIF information to the new jpg file? (I understand I will need to modify only few tags). I find very useful information on how to read the EXIF metadata in R (eg, packages Thermimage or exiftoolr), but not on writing them.


Solution

  • The exiftoolr package allows you to call exif_call() to run any command that the underlying exiftool can do. Examples are included here: https://exiftool.org/examples.html. So if you wanted to run the following command in R you would translate

    exiftool -artist="Phil Harvey" -copyright="2011 Phil Harvey" a.jpg
    

    into

    exiftoolr::exif_call(args=c(
       '-artist="Phil Harvey"', 
       '-copyright="2011 Phil Harvey"'
     ), 
     path="a.jpg")