XMP

## XMP XMP — Extensible Metadata Platform (XMP) |

## Stability Level

Stable, unless otherwise indicated

## Synopsis

    #include <libtracker-extract/tracker-extract.h>

                        TrackerXmpData;
                        TrackerXmpRegion;
    TrackerXmpData *    tracker_xmp_new                     (const gchar *buffer,
                                                             gsize len,
                                                             const gchar *uri);
    void                tracker_xmp_free                    (TrackerXmpData *data);
    gboolean            tracker_xmp_read                    (const gchar *buffer,
                                                             size_t len,
                                                             const gchar *uri,
                                                             TrackerXmpData *data);
    gboolean            tracker_xmp_apply                   (TrackerSparqlBuilder *preupdate,
                                                             TrackerSparqlBuilder *metadata,
                                                             const gchar *graph,
                                                             GString *where,
                                                             const gchar *uri,
                                                             TrackerXmpData *data);
    gboolean            tracker_xmp_apply_regions           (TrackerSparqlBuilder *preupdate,
                                                             TrackerSparqlBuilder *metadata,
                                                             const gchar *graph,
                                                             TrackerXmpData *data);

## Description

The Adobe Extensible Metadata Platform (XMP) is a standard, created by Adobe Systems Inc., for processing and storing standardized and proprietary information relating to the contents of a file.

XMP standardizes the definition, creation, and processing of extensible metadata. Serialized XMP can be embedded into a significant number of popular file formats, without breaking their readability by non-XMP-aware applications. Embedding metadata ("the truth is in the file") avoids many problems that occur when metadata is stored separately. XMP is used in PDF, photography and photo editing applications.

This API is provided to remove code duplication between extractors using these standards.

## Details

### TrackerXmpData

    typedef struct {
    	/* NS_DC */
    	gchar *title;
    	gchar *rights;
    	gchar *creator;
    	gchar *description;
    	gchar *date;
    	gchar *keywords;
    	gchar *subject;
    	gchar *publisher;
    	gchar *contributor;
    	gchar *type;
    	gchar *format;
    	gchar *identifier;
    	gchar *source;
    	gchar *language;
    	gchar *relation;
    	gchar *coverage;

    	/* NS_CC */
    	gchar *license;

    	/* NS_PDF */
    	gchar *pdf_title;
    	gchar *pdf_keywords;

    	/* NS_EXIF */
    	gchar *title2;
    	gchar *time_original;
    	gchar *artist;
    	gchar *make;
    	gchar *model;
    	gchar *orientation;
    	gchar *flash;
    	gchar *metering_mode;
    	gchar *exposure_time;
    	gchar *fnumber;
    	gchar *focal_length;
    	gchar *iso_speed_ratings;
    	gchar *white_balance;
    	gchar *copyright;

    	/* TODO NS_XAP*/
    	gchar *rating;

    	/* TODO NS_IPTC4XMP */
    	/* TODO NS_PHOTOSHOP */
    	gchar *address;
    	gchar *country;
    	gchar *state;
    	gchar *city;

    	/* ABI barrier (don't change things above this) */
    	gchar *gps_altitude;
    	gchar *gps_altitude_ref;
    	gchar *gps_latitude;
    	gchar *gps_longitude;
    	gchar *gps_direction;

    	/* List of TrackerXmpRegion */
    	GSList *regions;
    } TrackerXmpData;

Structure defining XMP data of a given file.

gchar *`title`; | Value for the dc:title property.
gchar *`rights`; | Value for the dc:rights property.
gchar *`creator`; | Value for the dc:creator property.
gchar *`description`; | Value for the dc:description property.
gchar *`date`; | Value for the dc:date property.
gchar *`keywords`; | Value for the dc:keywords property.
gchar *`subject`; | Value for the dc:subject property.
gchar *`publisher`; | Value for the dc:publisher property.
gchar *`contributor`; | Value for the dc:contributor property.
gchar *`type`; | Value for the dc:type property.
gchar *`format`; | Value for the dc:format property.
gchar *`identifier`; | Value for the dc:identifier property.
gchar *`source`; | Value for the dc:source property.
gchar *`language`; | Value for the dc:language property.
gchar *`relation`; | Value for the dc:relation property.
gchar *`coverage`; | Value for the dc:coverage property.
gchar *`license`; | Value for the nie:license property.
gchar *`pdf_title`; | Title of the PDF.
gchar *`pdf_keywords`; | Keywords in the PDF.
gchar *`title2`; | Title from the EXIF data.
gchar *`time_original`; | Original time from the EXIF data.
gchar *`artist`; | Artist from the EXIF data.
gchar *`make`; | Make info from the EXIF data.
gchar *`model`; | Model from the EXIF data.
gchar *`orientation`; | Orientation info from the EXIF data.
gchar *`flash`; | Flash info from the EXIF data.
gchar *`metering_mode`; | Metering mode from the EXIF data.
gchar *`exposure_time`; | Exposure time from the EXIF data.
gchar *`fnumber`; | Focal ratio from the EXIF data.
gchar *`focal_length`; | Focal length from the EXIF data.
gchar *`iso_speed_ratings`; | ISO speed ratings from the EXIF data.
gchar *`white_balance`; | White balance info from the EXIF data.
gchar *`copyright`; | Copyright info from the EXIF data.
gchar *`rating`; | Rating.
gchar *`address`; | Address.
gchar *`country`; | Country.
gchar *`state`; | State.
gchar *`city`; | City.
gchar *`gps_altitude`; | GPS altitude.
gchar *`gps_altitude_ref`; | GPS altitude reference.
gchar *`gps_latitude`; | GPS latitude.
gchar *`gps_longitude`; | GPS longitude.
gchar *`gps_direction`; | GPS direction information.
GSList *`regions`; | List of TrackerXmpRegion items.

### TrackerXmpRegion

    typedef struct {
    	gchar *title;
    	gchar *description;
    	gchar *type;
    	gchar *x;
    	gchar *y;
    	gchar *width;
    	gchar *height;
    	gchar *link_class;
    	gchar *link_uri;
    } TrackerXmpRegion;

Structure defining data of a given region in a TrackerXmpData.

gchar *`title`; | Title of the region.
gchar *`description`; | Description of the region.
gchar *`type`; | Type of the region.
gchar *`x`; | X axis position.
gchar *`y`; | Y axis position.
gchar *`width`; | Width.
gchar *`height`; | Height.
gchar *`link_class`; | Link class.
gchar *`link_uri`; | Link URI.

### tracker_xmp_new ()

    TrackerXmpData *    tracker_xmp_new                     (const gchar *buffer,
                                                             gsize len,
                                                             const gchar *uri);

This function takes `len` bytes of `buffer` and runs it through the XMP library.

`buffer` : | a chunk of data with xmp data in it.
`len` : | the size of `buffer`.
`uri` : | the URI this is related to.
Returns : | a newly allocated TrackerXmpData struct if XMP data was found, `NULL` otherwise. Free the returned struct with `tracker_xmp_free()`.

Since 0.10

### tracker_xmp_free ()

    void                tracker_xmp_free                    (TrackerXmpData *data);

Frees `data` and all TrackerXmpData members. `NULL` will produce a a warning.

`data` : | a TrackerXmpData struct

Since 0.10

### tracker_xmp_read ()

    gboolean            tracker_xmp_read                    (const gchar *buffer,
                                                             size_t len,
                                                             const gchar *uri,
                                                             TrackerXmpData *data);

### Warning

`tracker_xmp_read` is deprecated and should not be used in newly-written code. 0.9. Use `tracker_xmp_new()` instead.

This function takes `len` bytes of `buffer` and runs it through the XMP library. The result is that `data` is populated with the XMP data found in `uri`.

`buffer` : | a chunk of data with xmp data in it.
`len` : | the size of `buffer`.
`uri` : | the URI this is related to.
`data` : | a pointer to a TrackerXmpData structure to populate.
Returns : | `TRUE` if the `data` was populated successfully, otherwise `FALSE` is returned.

Since 0.8

### tracker_xmp_apply ()

    gboolean            tracker_xmp_apply                   (TrackerSparqlBuilder *preupdate,
                                                             TrackerSparqlBuilder *metadata,
                                                             const gchar *graph,
                                                             GString *where,
                                                             const gchar *uri,
                                                             TrackerXmpData *data);

This function applies all data in `data` to `metadata`.

The `graph` parameter was added in 0.12.

This function also calls `tracker_xmp_apply_regions()`, so there is no need to call both functions.

`preupdate` : | the preupdate object to apply XMP data to.
`metadata` : | the metadata object to apply XMP data to.
`graph` : | the graph to apply XMP data to.
`where` : | the where object.
`uri` : | the URI this is related to.
`data` : | the data to push into `metadata`.
Returns : | `TRUE` if the `data` was applied to `metadata` successfully, otherwise `FALSE` is returned.

Since 0.8

### tracker_xmp_apply_regions ()

    gboolean            tracker_xmp_apply_regions           (TrackerSparqlBuilder *preupdate,
                                                             TrackerSparqlBuilder *metadata,
                                                             const gchar *graph,
                                                             TrackerXmpData *data);

This function applies all regional `data` to `preupdate` and `metadata`. Regional data exists for image formats like JPEG, PNG, etc. where parts of the image refer to areas of interest. This can be people's faces, places to focus, barcodes, etc. The regional data describes the title, height, width, X, Y and can occur multiple times in a given file.

This data usually is standardized between image formats and that's what makes this function different to `tracker_xmp_apply()` which is useful for XMP files only.

`preupdate` : | the preupdate object to apply XMP data to.
`metadata` : | the metadata object to apply XMP data to.
`graph` : | the graph to apply XMP data to.
`data` : | the data to push into `preupdate` and `metadata`.
Returns : | `TRUE` if the `data` was applied to `preupdate` and `metadata` successfully, otherwise `FALSE` is returned.

Since 0.12