Learn R Programming

camtrapR (version 0.97.0)

TimeShiftImages: Apply time shifts to jpg image metadata

Description

Change the values of digital timestamps in image metadata using Exiftool. If date/time of images were set incorrectly, they can be easily corrected in batch mode for further analyses. Please, always make a backup of your data before using this function to avoid data loss or damage.

Usage

TimeShiftImages (inDir,
  TimeShiftTable,
  stationCol,
  cameraCol,
  hasCameraSubfolders,
  TimeShiftColumn,
  TimeShiftSignColumn,
  undo = FALSE
)

Arguments

inDir
character. Directory containing station directories with images
TimeShiftTable
data.frame containing information about station-/camera-specific time shifts.
stationCol
character. name of the column specifying Station ID in TimeShiftTable
cameraCol
character. name of the column specifying Camera ID in TimeShiftTable (optional)
hasCameraSubfolders
logical. Apply time shifts to camera-subdirectories only?
TimeShiftColumn
character. The name of the column containing time shift values in TimeShiftTable
TimeShiftSignColumn
character. The name of the column with the direction of time shifts in TimeShiftTable. Can only be "-" or "+".
undo
logical. Undo changes and restore the original images? Please be careful, this deletes any edited images if TRUE

Value

  • A data.frame containing the information about the processed directories and the number of images.

Details

TimeShiftTable is a data frame with columns for station ID, camera ID (optional), time shift value and direction of time shift. Images in inDir are expected to be sorted into station directories. If hasCameraSubfolders = TRUE, the function will look for camera subdirectories of the station directories and only apply time shifts to the camera subdirectories specified by CameraCol in TimeShiftTable. If hasCameraSubfolders = FALSE, shifts will be applied to the whole station directory (including potential subdirectories). The values of TimeShiftColumn should adhere to the following pattern: "Y:M:D H:M:S", i.e. "1:0:0 0:0:0" is a shift of exactly 1 year and "0:0:0 12:10:01" 12 hours and 10 minutes and 1 second. TimeShiftSignColumn signifies the direction of the time shift. "+" moves image dates into the future (i.e. the image date lagged behind the actual date) and "-" moves image dates back (if the image dates were ahead of actual time). Exiftool stores the original images as .JPG_original files in the original file location. By setting undo = TRUE, any JPG files in the directories specified by TimeShiftTable will be deleted and the original jpgs will be restored from the JPG_original files. Please make a backup before using undo.

References

http://www.sno.phy.queensu.ca/~phil/exiftool/Shift.html

Examples

Run this code
# define image directory
wd_images_ID <- system.file("pictures/sample_images", package = "camtrapR")
file.copy(from = wd_images_ID, to = getwd(), recursive = TRUE)
wd_images_ID_copy <- paste(getwd(), "sample_images", sep = "/")

data(timeShiftTable)


timeshift_run <- TimeShiftImages(inDir = wd_images_ID_copy,
  TimeShiftTable = timeShiftTable,
  stationCol = "Station",
  hasCameraSubfolders = FALSE,
  TimeShiftColumn = "timeshift",
  TimeShiftSignColumn = "sign",
  undo = FALSE
)


timeshift_undo <- TimeShiftImages(inDir = wd_images_ID_copy,
  TimeShiftTable = timeShiftTable,
  stationCol = "Station",
  hasCameraSubfolders = FALSE,
  TimeShiftColumn = "timeshift",
  TimeShiftSignColumn = "sign",
  undo = TRUE
)

Run the code above in your browser using DataLab