Skip to contents

The function extracts metadata from image files located at a specified path. The function can handle both individual image files and directories containing multiple images. It uses the exiftool utility to read the metadata and can optionally save the extracted metadata to a CSV file.

Usage

mm_get_metadata(path, recursive = FALSE, save_file = FALSE, file_name = "")

Arguments

path

a character vector of full path names. Either a directory path or file path. If the path specified is a directory, the function looks for all image (.jpeg/JPEG, jpg/JPG) inside and extract the tags and bind in a single data.frame.

recursive

logical. Should the listing recurse into directories? It is applied if path is directory.

save_file

logical. Extracted metadata should be write on disk?

file_name

a character specifying the name of file to save in csv format. If left empty and save_file is TRUE, the default name is metadata.csv. Note that the file is not saved if save_file is FALSE, even if the file name is provided.

Value

data.frame

Examples


# Image path
image_path <- file.path(system.file("img", package = "maimer"), "large.jpeg")

# Extract metadata from the downloaded image
metadata <- mm_get_metadata(path = image_path)

# Extract metadata from all images in a directory (non-recursive)
file.copy(image_path, file.path(dirname(image_path), "large2.jpeg"))
#> [1] TRUE
metadata_dir <- mm_get_metadata(path = dirname(image_path), recursive = FALSE)
#> Processing image large.jpeg (1 of 2)
#> Processing image large2.jpeg (2 of 2)

unlink(file.path(dirname(image_path), "large2.jpeg"))