get_xmp() gets xmp metadata from a file. set_xmp() sets xmp metadata for a file.

get_xmp(filename, use_names = TRUE)

get_xmp_exiftool(filename, use_names = TRUE)

set_xmp(xmp, input, output = input)

set_xmp_exiftool(xmp, input, output = input)

Arguments

filename

Filename(s) to extract xmp metadata from.

use_names

If TRUE (default) use filename as the names of the result.

xmp

An xmp() object.

input

Input filename.

output

Output filename.

Value

get_xmp() returns a list of xmp() objects. set_xmp() returns the (output) filename invisibly.

Details

get_xmp() will try to use the following helper functions in the following order:

  1. get_xmp_exiftool() which wraps exiftool command-line tool

set_xmp() will try to use the following helper functions in the following order:

  1. set_xmp_exiftool() which wraps exiftool command-line tool

See also

xmp() for more information about xmp metadata objects. supports_get_xmp(), supports_set_xmp(), and supports_exiftool() to detect support for these features. For more info about xmp metadata see https://www.exiftool.org/TagNames/XMP.html.

Examples

  x <- xmp(attribution_url = "https://example.com/attribution",
           creator = "John Doe",
           description = "An image caption",
           date_created = Sys.Date(),
           spdx_id = "CC-BY-4.0")
  print(x)
#> i  spdx_id (not XMP tag) := CC-BY-4.0
#> i  auto_xmp (not XMP tag) := cc:attributionName, cc:license, dc:rights, dc:subject,
#>         photoshop:Credit, xmpRights:Marked, xmpRights:UsageTerms,
#>         xmpRights:WebStatement
#> => cc:attributionName = John Doe
#>    cc:attributionURL := https://example.com/attribution
#> => cc:license = https://creativecommons.org/licenses/by/4.0/
#>    dc:creator := John Doe
#>    dc:description := An image caption
#> => dc:rights = © 2024 John Doe. Some rights reserved.
#> => photoshop:Credit = John Doe
#>    photoshop:DateCreated := 2024-03-29
#> => xmpRights:Marked = TRUE
#> => xmpRights:UsageTerms = This work is licensed to the public under the Creative Commons
#>         Attribution 4.0 International license
#>         https://creativecommons.org/licenses/by/4.0/
#> => xmpRights:WebStatement = https://creativecommons.org/licenses/by/4.0/
  print(x, mode = "google_images", xmp_only = TRUE)
#>    dc:creator := John Doe
#> => dc:rights = © 2024 John Doe. Some rights reserved.
#> => photoshop:Credit = John Doe
#> X  plus:Licensor (not currently supported by {xmpdf})
#> => xmpRights:WebStatement = https://creativecommons.org/licenses/by/4.0/
  print(x, mode = "creative_commons", xmp_only = TRUE)
#> => cc:attributionName = John Doe
#>    cc:attributionURL := https://example.com/attribution
#> => cc:license = https://creativecommons.org/licenses/by/4.0/
#>    cc:morePermissions := NULL
#> => dc:rights = © 2024 John Doe. Some rights reserved.
#> => xmpRights:Marked = TRUE
#> => xmpRights:UsageTerms = This work is licensed to the public under the Creative Commons
#>         Attribution 4.0 International license
#>         https://creativecommons.org/licenses/by/4.0/
#> => xmpRights:WebStatement = https://creativecommons.org/licenses/by/4.0/

  if (supports_set_xmp() &&
      supports_get_xmp() &&
      capabilities("png") &&
      requireNamespace("grid", quietly = TRUE)) {

    f <- tempfile(fileext = ".png")
    png(f)
    grid::grid.text("This is an image!")
    invisible(dev.off())
    set_xmp(x, f)
    print(get_xmp(f)[[1]])
  }
#>    cc:attributionName := John Doe
#>    cc:attributionURL := https://example.com/attribution
#>    cc:license := https://creativecommons.org/licenses/by/4.0/
#>    dc:creator := John Doe
#>    dc:description := An image caption
#>    dc:rights := © 2024 John Doe. Some rights reserved.
#>    photoshop:Credit := John Doe
#>    photoshop:DateCreated := 2024-03-29
#>    x:XMPToolkit := Image::ExifTool 12.40
#>    xmpRights:Marked := TRUE
#>    xmpRights:UsageTerms := This work is licensed to the public under the Creative Commons
#>         Attribution 4.0 International license
#>         https://creativecommons.org/licenses/by/4.0/
#>    xmpRights:WebStatement := https://creativecommons.org/licenses/by/4.0/