A container for all the metadata embedded in an image.
It provides convenient methods for the manipulation of EXIF, IPTC and XMP metadata embedded in image files such as JPEG and TIFF files, using Python types. It also provides access to the previews embedded in an image.
Instantiate an image container from an image buffer.
Parameter: | buffer (string) – a buffer containing image data |
---|
Write the metadata back to the image.
Parameter: | preserve_timestamps (boolean) – whether to preserve the file’s original timestamps (access time and modification time) |
---|
Get a metadata tag for a given key.
Parameter: | key (string) – metadata key in the dotted form familyName.groupName.tagName where familyName may be one of exif, iptc or xmp. |
---|---|
Raises KeyError: | |
if the tag doesn’t exist |
Set a metadata tag for a given key. If the tag was previously set, it is overwritten. As a handy shortcut, a value may be passed instead of a fully formed tag. The corresponding tag object will be instantiated.
Parameters: |
|
---|---|
Raises KeyError: | |
if the key is invalid |
Delete a metadata tag for a given key.
Parameter: | key (string) – metadata key in the dotted form familyName.groupName.tagName where familyName may be one of exif, iptc or xmp. |
---|---|
Raises KeyError: | |
if the tag with the given key doesn’t exist |
Copy the metadata to another image. The metadata in the destination is overridden. In particular, if the destination contains e.g. EXIF data and the source doesn’t, it will be erased in the destination, unless explicitly omitted.
Parameters: |
|
---|
Exception raised when failing to parse the value of an EXIF tag.
Attribute value: | |
---|---|
the value that fails to be parsed | |
Attribute type: | the EXIF type of the tag |
An EXIF tag.
Here is a correspondance table between the EXIF types and the possible python types the value of a tag may take:
A thumbnail image optionally embedded in the IFD1 segment of the EXIF data.
The image is either a TIFF or a JPEG image.
Set the EXIF thumbnail to the JPEG image path. This sets only the Compression, JPEGInterchangeFormat and JPEGInterchangeFormatLength tags, which is not all the thumbnail EXIF information mandatory according to the EXIF standard (but it is enough to work with the thumbnail).
Parameter: | path (string) – path to a JPEG file to set the thumbnail to |
---|
Write the thumbnail image to a file on disk. The file extension will be automatically appended to the path.
Parameter: | path (string) – path to write the thumbnail to (without an extension) |
---|
Exception raised when failing to parse the value of an IPTC tag.
Attribute value: | |
---|---|
the value that fails to be parsed | |
Attribute type: | the IPTC type of the tag |
An IPTC tag.
This tag can have several values (tags that have the repeatable property).
Here is a correspondance table between the IPTC types and the possible python types the value of a tag may take:
Register a custom XMP namespace.
Overriding the prefix of a known or previously registered namespace is not allowed.
Parameters: |
|
---|---|
Raises ValueError: | |
if the name doesn’t end with a / |
|
Raises KeyError: | |
if a namespace already exist with this prefix |
Unregister a custom XMP namespace.
A custom namespace is identified by its name, not by its prefix.
Attempting to unregister an unknown namespace raises an error, as does attempting to unregister a builtin namespace.
Parameter: | name (string) – the name of the custom namespace (ending with a /), typically a URL (e.g. http://purl.org/dc/elements/1.1/) |
---|---|
Raises ValueError: | |
if the name doesn’t end with a / | |
Raises KeyError: | |
if the namespace is unknown or a builtin namespace |
Unregister all custom XMP namespaces.
Builtin namespaces are not unregistered.
This function always succeeds.
Exception raised when failing to parse the value of an XMP tag.
Attribute value: | |
---|---|
the value that fails to be parsed | |
Attribute type: | the XMP type of the tag |
An XMP tag.
Here is a correspondance table between the XMP types and the possible python types the value of a tag may take:
A preview image (properties and data buffer) embedded in image metadata.
Write the preview image to a file on disk. The file extension will be automatically appended to the path.
Parameter: | path (string) – path to write the preview to (without an extension) |
---|
Convert an undefined string into its corresponding sequence of bytes. The undefined string must contain the ascii codes of a sequence of bytes, separated by white spaces (e.g. “48 50 50 49” will be converted into “0221”). The Undefined type is part of the EXIF specification.
Parameter: | undefined (string) – an undefined string |
---|---|
Returns: | the corresponding decoded string |
Return type: | string |
Convert a string into its undefined form. The undefined form contains a sequence of ascii codes separated by white spaces (e.g. “0221” will be converted into “48 50 50 49”). The Undefined type is part of the EXIF specification.
Parameter: | sequence (string) – a sequence of bytes |
---|---|
Returns: | the corresponding undefined string |
Return type: | string |
A class representing a rational number.
Its numerator and denominator are read-only properties.
Instantiate a Rational from a string formatted as [-]numerator/denominator.
Parameter: | string (string) – a string representation of a rational number |
---|---|
Returns: | the rational number parsed |
Return type: | Rational |
Raises ValueError: | |
if the format of the string is invalid |
Returns: | a floating point number approximation of the value |
---|---|
Return type: | float |
A class representing GPS coordinates (e.g. a latitude or a longitude).
Its attributes (degrees, minutes, seconds, direction) are read-only properties.
Instantiate a GPSCoordinate from a string formatted as DDD,MM,SSk or DDD,MM.mmk where DDD is a number of degrees, MM is a number of minutes, SS is a number of seconds, mm is a fraction of minutes, and k is a single character N, S, E, W indicating a direction (north, south, east, west).
Parameter: | string (string) – a string representation of a GPS coordinate |
---|---|
Returns: | the GPS coordinate parsed |
Return type: | GPSCoordinate |
Raises ValueError: | |
if the format of the string is invalid |
Compare two GPS coordinates for equality.
Two coordinates are equal if and only if all their components are equal.
Parameter: | other (GPSCoordinate) – the GPS coordinate to compare to self for equality |
---|---|
Returns: | True if equal, False otherwise |
Return type: | boolean |
Returns: | a string representation of the GPS coordinate conforming to the XMP specification |
---|---|
Return type: | string |