Convert image file formats while preserving EXIF data

uas_convert(
  x,
  dir_out = NULL,
  idx = NULL,
  format_out = c("jpg", "tif")[1],
  quality = 90,
  copy_exif = TRUE,
  overwrite = FALSE,
  quiet = FALSE
)

Arguments

x

A vector of filenames (with path), or an object of class 'uas_info'

dir_out

The output directory(s)

idx

Row numbers of the images (optional)

format_out

The output format

quality

The quality level for jpg compression (0..100), larger numbers produce better image quality

copy_exif

Whether to copy the original EXIF info to the new file, logical

overwrite

Overwrite existing files, logical

quiet

Suppress messages, logical

Details

This function converts image formats. Images are converted using the `magick` package (which calls ImageMagick libraries), while EXIF data is copied using exiftool. Supported output formats include JPG and TIFF.

x can be a vector of image file names (including the path), or a image metadata object (created by uas_info). If idx (row numbers) is passed, it will be used to select images to convert.

dir_out is the name of the directory where converted images will be output. If NULL, images will be placed in the same directory as the input images. If x is an object of class `uas_info`, dir_out can be a vector of directories equal in length to the number of folders indexed in x (in which case the converted images will be placed in the corresponding output directory).

quality sets the compression ratio for jpg images. To preserve a high level of fidelity and improve the odds of successful stitching, it is recommended you set quality to 90 or higher. If format_out = "tif", the output files will be saved as uncompressed tif files.

Examples

if (FALSE) {
## Make a list of DNG files to convert
files_dng <- list.files("D:/uas/mavic_pro/raw",
                        pattern = ".DNG$",
                        full.names = TRUE,
                        ignore.case = TRUE)

uas_convert(files_dng,
            dir_out = "D:/uas/mavic_pro/jpg",
            format_out = "jpg")
}