xmp() creates an XMP metadata object.
Such objects can be used with set_xmp() to edit XMP medata for a variety of media formats
and such objects are returned by get_xmp().
Usage
xmp(
...,
alt_text = NULL,
attribution_name = NULL,
attribution_url = NULL,
create_date = NULL,
creator = NULL,
creator_tool = NULL,
credit = NULL,
date_created = NULL,
description = NULL,
ext_description = NULL,
headline = NULL,
keywords = NULL,
license = NULL,
marked = NULL,
modify_date = NULL,
more_permissions = NULL,
producer = NULL,
rights = NULL,
subject = NULL,
title = NULL,
usage_terms = NULL,
web_statement = NULL,
auto_xmp = c("cc:attributionName", "cc:license", "dc:rights", "dc:subject",
"photoshop:Credit", "xmpRights:Marked", "xmpRights:UsageTerms",
"xmpRights:WebStatement"),
spdx_id = NULL
)Arguments
- ...
Entries of xmp metadata. The names are either the xmp tag names or alternatively the xmp namespace and tag names separated by ":". The values are the xmp values.
- alt_text
Brief textual description that can be used as its "alt text" (XMP tag
Iptc4xmpCore:AltTextAccessibility). Will be coerced byas_lang_alt(). Core IPTC photo metadata.- attribution_name
The name to be used when attributing the work (XMP tag
cc:attributionName). Recommended by Creative Commons. If missing and"cc:attributionName"inauto_xmpand andphotoshop:Creditnon-missing will use that else ifdc:creatornon-missing then will automatically usestringi::stri_join(creator, collapse = " and ").- attribution_url
The URL to be used when attributing the work (XMP tag
cc:attributionURL). Recommended by Creative Commons.- create_date
The date the digital document was created (XMP tag
xmp:CreateDate). Will be coerced bydatetimeoffset::as_datetimeoffset(). Related pdf documentation info key isCreationDate. Not to be confused withphotoshop:DateCreatedwhich is the date the intellectual content was created.- creator
The document's author(s) (XMP tag
dc:creator). Related pdf documentation info key isAuthor. Core IPTC photo metadata used by Google Photos. Ifcreditis missing and"photoshop:Credit"inauto_xmpthen we'll also use this for thephotoshop:CreditXMP tag.- creator_tool
The name of the application that originally created the document (XMP tag
xmp:CreatorTool). Related pdf documentation info key isCreator.- credit
Credit line field (XMP tag
photoshop:Credit). Core IPTC photo metadata used by Google Photos. If missing and"photoshop:Credit"inauto_xmpanddc:creatornon-missing then will automatically usestringi::stri_join(creator, collapse = " and ").- date_created
The date the intellectual content was created (XMP tag
photoshop:DateCreated). Will be coerced bydatetimeoffset::as_datetimeoffset(). Core IPTC photo metadata. Not to be confused withxmp:CreateDatefor when the digital document was created.- description
The document's subject (XMP tag
dc:description). Will be coerced byas_lang_alt(). Core IPTC photo metadata. Related pdf documentation info key isSubject.- ext_description
An extended description (for accessibility) if the "alt text" is insufficient (XMP tag
Iptc4xmpCore:ExtDescrAccessibility). Will be coerced byas_lang_alt(). Core IPTC photo metadata.- headline
A short synopsis of the document (XMP tag
photoshop:Headline). Core IPTC photo metadata.- keywords
Character vector of keywords for this document (for cross-document searching). Related pdf documentation info key is
pdf:Keywords. Will be coerced into a string bystringi::stri_join(keywords, collapse = ", ").- license
The URL of (open source) license terms (XMP tag
cc:license). Recommended by Creative Commons. NotexmpRights:WebStatementset inweb_statementis a more popular XMP tag (e.g. used by Google Images) that can also hold the URL of license terms or a verifying web statement. Ifcc:licenseinauto_xmpandspdx_idis notNULLthen we'll automatically use an URL from spdx_licenses corresponding to that license.- marked
Whether the document is a rights-managed resource (XMP tag
xmpRights:Marked). UseTRUEif rights-managed,FALSEif public domain, andNULLif unknown. Creative Commons recommends setting this. IfxmpRights:Markedinauto_xmpandspdx_idis notNULLthen we can automatically set this for a subset of SPDX licenses (including all Creative Commons licenses).- modify_date
The date the document was last modified (XMP tag
xmp:ModifyDate). Will be coerced bydatetimeoffset::as_datetimeoffset(). Related pdf documentation info key isModDate.- more_permissions
A URL for additional permissions beyond the
license(XMP tagcc:morePermissions). Recommended by Creative Commons. Contrast with theLicensorURLproperty ofplus:LicensorXMP tag.- producer
The name of the application that converted the document to pdf (XMP tag
pdf:Producer). Related pdf documentation info key isProducer.- rights
(copy)right information about the document (XMP tag
dc:rights). Will be coerced byas_lang_alt(). Core IPTC photo metadata used by Google Photos that Creative Commons also recommends setting. Ifdc:rightsinauto_xmpandcreatoranddate_createdare notNULLthen we can automatically generate a basic copyright statement with the help ofspdx_id.- subject
List of description phrases, keywords, classification codes (XMP tag
dc:subject). Core IPTC photo metadata. A character vector. Similar but less popular to the XMP tagpdf:Keywordswhich is a string. Ifdc:subjectinauto_xmpandkeywordsis not NULL then we can automatically extract the keywords from it usingstrsplit(keywords, ", ")[[1]].- title
The document's title (XMP tag
dc:title). Will be coerced byas_lang_alt(). Related pdf documentation info key isTitle.- usage_terms
A string describing legal terms of use for the document (XMP tag
xmpRights:UsageTerms). Will be coerced byas_lang_alt(). Core IPTC photo metadata and recommended by Creative Commons. IfxmpRights:UsageTermsinauto_xmpandspdx_idis notNULLthen we can automatically set this with that license's name and URL.- web_statement
Web Statement of Rights (XMP tag
xmpRights:WebStatement): a string of a full URL with license information about the page. IfxmpRights:WebStatementinauto_xmpandspdx_idis notNULLthen we'll automatically use an URL from spdx_licenses corresponding to that license. Core IPTC photo metadata used by Google Photos. Also recommended by Creative Commons (who also recommends using a "verifying" web statement).- auto_xmp
Character vector of XMP metadata we should try to automatically determine if missing from other XMP metadata and
spdx_id.- spdx_id
The id of a license in the SPDX license list. See spdx_licenses.
Value
An xmp object as can be used with set_xmp(). Basically a named list whose names are the (optional) xmp namespace and tag names separated by ":" and the values are the xmp values.
Datetimes should be a datetime object such as POSIXlt().
xmp R6 Class Methods
fig_process(..., auto = c("fig.alt", "fig.cap", "fig.scap"))Returns a function to embed XMP metadata suitable for use with
{knitr}'sfig.processchunk option....are local XMP metadata changes for this function.autoare which chunk options should be used to further update metadata values.get_item(key)Get XMP metadata value for key
key. Can also use the relevant active bindings to get more common values.print(mode = c("null_omit", "google_images", "creative_commons", "all"), xmp_only = FALSE)Print out XMP metadata values. If
modeis "null_omit" print out which metadata would be embedded. Ifmodeis "google images" print out values for the five fields Google Images uses. Ifmodeiscreative_commonsprint out the values for the fields Creative Commons recommends be set when using their licenses. If mode isallprint out values for all XMP metadata that we provide active bindings for (even ifNULL). Ifxmp_onlyisTRUEthen don't print outspdx_idandauto_xmpvalues.set_item(key, value)Set XMP metadata key
keywith valuevalue. Can also use the relevant active bindings to set XMP metadata values.update(x)Update XMP metadata entries using non-
NULLentries inxcoerced byas_xmp().
xmp R6 Active Bindings
alt_textThe image's alt text (accessibility).
attribution_nameThe name to attribute the document.
attribution_urlThe URL to attribute the document.
create_dateThe date the document was created.
creatorThe document's author.
creator_toolThe name of the application that originally created the document.
creditCredit line.
date_createdThe date the document's intellectual content was created
descriptionThe document's description.
ext_descriptionAn extended description for accessibility.
headlineA short synopsis of document.
keywordsString of keywords for this document (less popular than
subject)).licenseURL of (open-source) license terms the document is licensed under.
markedBoolean of whether this is a rights-managed document.
modify_dateThe date the document was last modified.
more_permissionsURL for acquiring additional permissions beyond
license.producerThe name of the application that converted the document (to pdf).
rightsThe document's copy(right) information.
subjectVector of key phrases/words/codes for this document (more popular than
keywords)).titleThe document's title.
usage_termsThe document's rights usage terms.
web_statementA URL string for the web statement of rights for the document.
spdx_idThe id of a license in the SPDX license list. See spdx_licenses.
auto_xmpCharacter vector of XMP metadata we should try to automatically determine if missing from other XMP metadata and
spdx_id.
XMP tag recommendations
https://exiftool.sourceforge.net/TagNames/XMP.html recommends "dc", "xmp", "Iptc4xmpCore", and "Iptc4xmpExt" schemas if possible
https://github.com/adobe/xmp-docs/tree/master/XMPNamespaces are descriptions of some common XMP tags
https://www.iptc.org/std/photometadata/specification/IPTC-PhotoMetadata#xmp-namespaces-and-identifiers is popular for photos
https://developers.google.com/search/docs/appearance/structured-data/image-license-metadata#iptc-photo-metadata are the subset of IPTC photo metadata which Google Photos uses (if no structured data on web page)
https://wiki.creativecommons.org/wiki/XMP are Creative Commons license recommendations
See also
get_xmp() and set_xmp() for getting/setting such information from/to a variety of media file formats.
as_xmp() for coercing to this object.
as_docinfo() can be used to coerce xmp() objects into docinfo() objects.
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 = © 2026 John Doe. Some rights reserved.
#> => photoshop:Credit = John Doe
#> photoshop:DateCreated := 2026-08-25
#> => 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 = © 2026 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 = © 2026 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 := © 2026 John Doe. Some rights reserved.
#> photoshop:Credit := John Doe
#> photoshop:DateCreated := 2026-08-25
#> 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/