Image.Xmp (image v0.71.0)

Copy Markdown View Source

Functions to extract and interpret image XMP data.

Summary

Functions

Extracts an XMP metadata blob into an Elixir map.

Functions

extract_xmp(xmp)

@spec extract_xmp(binary() | tuple()) :: map()

Extracts an XMP metadata blob into an Elixir map.

Arguments

  • xmp is either the raw XMP XML payload as a string, or a parsed SweetXml xml element. This is the form libvips returns from Vix.Vips.Image.header_value(image, "xmp-data").

Returns

  • A map keyed by atom field names (:artist, :keywords, :created_at, :rating, …) with the parsed values.

Examples

iex> image = Image.open!("./test/support/images/Kip_small.jpg")
iex> {:ok, xmp} = Vix.Vips.Image.header_value(image, "xmp-data")
iex> xmp_map = Image.Xmp.extract_xmp(xmp)
iex> xmp_map.artist
"Kip Cole"
iex> xmp_map.created_at
~N[2004-09-11 16:06:57]