A tuple containing the three components of the version number: major, minor, micro.
The version of the module as a string (major.minor.micro).
A tuple containing the three components of the version number of libexiv2: major, minor, micro.
The version of libexiv2 as a string (major.minor.micro).
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.
Parameters: | buffer (string) – a buffer containing image data |
---|
Read the metadata embedded in the associated image. It is necessary to call this method once before attempting to access the metadata (an exception will be raised if trying to access metadata before calling this method).
Write the metadata back to the image.
Parameters: | preserve_timestamps (boolean) – whether to preserve the file’s original timestamps (access time and modification time) |
---|
A tuple containing the width and height of the image, expressed in pixels.
The mime type of the image, as a string.
List of the keys of the available EXIF tags.
List of the keys of the available IPTC tags.
An optional character set the IPTC data is encoded in.
List of the keys of the available XMP tags.
Get a metadata tag for a given key.
Parameters: | 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.
Parameters: | 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 |
The image comment.
List of the previews available in the image, sorted by increasing size.
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:
The key of the tag in the dotted form familyName.groupName.tagName where familyName = exif.
The EXIF type of the tag (one of Ascii, Byte, SByte, Comment, Short, SShort, Long, SLong, Rational, SRational, Undefined).
The name of the tag (this is also the third part of the key).
The title (label) of the tag.
The description of the tag.
The name of the tag’s section.
The description of the tag’s section.
The raw value of the tag as a string.
The value of the tag as a python object.
A (read-only) human-readable representation of the value of the tag.
A thumbnail image optionally embedded in the IFD1 segment of the EXIF data.
The image is either a TIFF or a JPEG image.
The mime type of the preview image (e.g. image/jpeg).
The file extension of the preview image with a leading dot (e.g. .jpg).
The raw thumbnail data. Setting it is restricted to a buffer in the JPEG format.
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).
Parameters: | 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.
Parameters: | path (string) – path to write the thumbnail to (without an extension) |
---|
Delete the thumbnail from the EXIF data. Removes all Exif.Thumbnail.*, i.e. Exif IFD1 tags.
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:
The key of the tag in the dotted form familyName.groupName.tagName where familyName = iptc.
The IPTC type of the tag (one of Short, String, Date, Time, Undefined).
The name of the tag (this is also the third part of the key).
The title (label) of the tag.
The description of the tag.
The Photoshop name of the tag.
Whether the tag is repeatable (accepts several values).
The name of the tag’s record.
The description of the tag’s record.
The raw values of the tag as a list of strings.
The values of the tag as a list of python objects.
Register a custom XMP namespace.
Overriding the prefix of a known or previously registered namespace is not allowed.
Parameters: |
|
---|---|
Raises: |
|
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.
Parameters: | name (string) – the name of the custom namespace (ending with a /), typically a URL (e.g. http://purl.org/dc/elements/1.1/) |
---|---|
Raises: |
|
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:
The key of the tag in the dotted form familyName.groupName.tagName where familyName = xmp.
The XMP type of the tag.
The name of the tag (this is also the third part of the key).
The title (label) of the tag.
The description of the tag.
The raw value of the tag as a [list of] string(s).
The value of the tag as a [list of] python object(s).
A preview image (properties and data buffer) embedded in image metadata.
The mime type of the preview image (e.g. image/jpeg).
The file extension of the preview image with a leading dot (e.g. .jpg).
The size of the preview image in bytes.
A tuple containing the width and height of the preview image in pixels.
The preview image data buffer.
Write the preview image to a file on disk. The file extension will be automatically appended to the path.
Parameters: | 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.
Parameters: | 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.
Parameters: | sequence (string) – a sequence of bytes |
---|---|
Returns: | the corresponding undefined string |
Return type: | string |
Make a fraction.
The type of the returned object depends on the availability of the fractions module in the standard library (Python ≥ 2.6).
Raises TypeError: | |
---|---|
if the arguments do not match the expected format for a fraction |
A class representing a rational number.
Its numerator and denominator are read-only properties.
Do not use this class directly to instantiate a rational number. Instead, use make_fraction().
The numerator of the rational number.
The denominator of the rational number.
Instantiate a Rational from a string formatted as [-]numerator/denominator.
Parameters: | 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 |
Compare two rational numbers for equality.
Two rational numbers are equal if their reduced forms are equal.
Parameters: | other (Rational) – the rational number to compare to self for equality |
---|---|
Returns: | True if equal, False otherwise |
Return type: | boolean |
Returns: | a string representation of the rational number |
---|---|
Return type: | string |
Returns: | the official string representation of the object |
---|---|
Return type: | string |
A class representing GPS coordinates (e.g. a latitude or a longitude).
Its attributes (degrees, minutes, seconds, direction) are read-only properties.
The degrees component of the coordinate.
The minutes component of the coordinate.
The seconds component of the coordinate.
The direction component of the coordinate.
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).
Parameters: | 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.
Parameters: | 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 |