RDF::Redland::Model::ExifTool - extends RDF model to read Exif meta data


RDF-Redland-Model-ExifTool documentation  | view source Contained in the RDF-Redland-Model-ExifTool distribution.

Index


NAME

Top

RDF::Redland::Model::ExifTool - extends RDF model to read Exif meta data

Using ExifTool and Redland RDF Libraries.

VERSION

Top

Version 0.15

SYNOPSIS

Top

    use Image::ExifTool;
    use RDF::Redland;
    use RDF::Redland::Model::ExifTool;

    # creates an empty RDF model in memory
    $storage = new RDF::Redland::Storage("hashes", "exif_meta_data",
                           "new='yes',hash-type='memory'");
    $model = new RDF::Redland::Model::ExifTool($storage, "");

    # reads Exif meta data from files and
    # processes into RDF statements in model
    $exiftool = new Image::ExifTool;
    foreach $file (@ARGV) {
        $exiftool->ImageInfo($file, $model->get_exif_tags);

        # prints any errors
        foreach $error ($model->add_exif_statements($exiftool)) {
            print STDERR $error . "\n";
        }
    }
    $model->sync;

    # prints any RDF statements with Turtle syntax
    if (0 < $model->size) {
        $SYNTAX = "turtle";
        $serializer = new RDF::Redland::Serializer($SYNTAX);
        $BASE_URI = "http://theflints.net.nz/";
        print $serializer->serialize_model_to_string(
                  new RDF::Redland::URINode($BASE_URI), $model);
        undef $serializer;
    }
    undef $model;
    undef $storage;

For a more complete example see script exif2rdf and the TUTORIAL in its documentation.

DESCRIPTION

Top

Exif meta data is in tag and value pairs. The ExifTool Perl library reads Exif meta data stored in files. RDF is in subject, predicate (verb) and object triples called statements. Redland Libraries have a Perl interface that parses and serializes RDF. For more details on ExifTool and Redland see Image::ExifTool and http://librdf.org/docs/perl.html.

This class extends the Redland model or set of RDF statements (RDF::Redland::Model) to read Exif meta data from instances of ExifTool (Image::ExifTool). The programmer can use all the features of ExifTool and Redland including RDF databases, querying and reasoning.

This class depends on non-core Perl modules and classes. All are available from CPAN except RDF::Redland see this class' README for details.

Configuration

This class' configuration is a hash of data structures that can be set from a file (with set_exif_config_from_file) or variable (set_exif_config). For example a configuration in a variable:

  $config = {

    # tries to parse RDF statements from value of Comment tag
    # with Turtle or RDF/XML syntax
    ParseTag => ["Comment"],
    ParseSyntax => ["turtle", "rdfxml"],

    # failing that translates Comment tag and value into an RDF statement
    TranslateTag => {
      Comment => "http://www.w3.org/2003/12/exif/ns#userComment",

      # translates Aperture and ShutterSpeed tags too
      Aperture => 
        "http://www.w3.org/2003/12/exif/ns#apertureValue",
      ShutterSpeed => 
        "http://www.w3.org/2003/12/exif/ns#shutterSpeedValue",
    },
  };

To dump the default configuration run this class' example script:

    exif2rdf --dump

ParseTag

list of Exif tags whose values are parsed for RDF statements for example Comment.

If ParseTag is set then ParseSyntax must be too. TranslateTag must be set if ParseTag is not.

ParseSyntax

list of Redland RDF syntax used to parse tag values, for example rdfxml, ntriples, turtle and guess. For a list of possible values run:

    rapper --help

and see the input FORMATs.

TranslateTag

hash of Exif tag and equivalent RDF predicate.

For the list of tags and their values in a file run:

    exiftool -s my.jpg

For the list of tags that ExifTool can read run:

    exiftool -list

ParseTag and ParseSyntax must be set if TranslateTag is not.

Predicates must be absolute HTTP URIs, here are some useful RDF schemas:

METHODS

Top

add_exif_statements

Processes Exif meta data from list of ExifTools into RDF statements stored in this model using Configuration.

Returns empty list if successful or list of error strings.

get_exif_config

Returns copy of this RDF model's Configuration.

get_exif_config_to_string

Returns copy of this RDF model's Configuration as string.

get_exif_tags

Returns list of Exif tags that can be processed by this RDF model, the tags in Configuration.

By default ExifTool's ImageInfo reads all tags but only a subset of those tags can be processed by a model. This method speeds up ExifTool by only getting those tags that this model can process. For example:

    $exiftool->ImageInfo("my.jpg", $model->get_exif_tags)

set_exif_config

Replaces this RDF model's Configuration.

Returns empty list if configuration replaced or list of error strings.

set_exif_config_from_file

Replaces this RDF model's Configuration from file.

Returns empty list if configuration replaced or list of error strings.

For example the configuration file:

    # Note: URI anchor char '#' must be escaped '\#' or 
    #       it is treated as a comment
    <TranslateTag>
      Aperture      http://www.w3.org/2003/12/exif/ns\#apertureValue
      Comment       http://www.w3.org/2003/12/exif/ns\#userComment
      ShutterSpeed  http://www.w3.org/2003/12/exif/ns\#shutterSpeedValue
    </TranslateTag>

    ParseTag Comment

    ParseSyntax turtle
    ParseSyntax rdfxml

is the equivalent of the variable Configuration.

AUTHOR

Top

Andrew Flint, <arnhemcr at cpan.org>

BUGS

Top

Please report any bugs or feature requests to bug-rdf-redland-model-exiftool at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=RDF-Redland-Model-ExifTool. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

Top

You can find documentation for this class with the perldoc command.

    perldoc RDF::Redland::Model::ExifTool

You can also look for information at:

* RT: CPAN's request tracker

http://rt.cpan.org/NoAuth/Bugs.html?Dist=RDF-Redland-Model-ExifTool

* AnnoCPAN: Annotated CPAN documentation

http://annocpan.org/dist/RDF-Redland-Model-ExifTool

* CPAN Ratings

http://cpanratings.perl.org/d/RDF-Redland-Model-ExifTool

* Search CPAN

http://search.cpan.org/dist/RDF-Redland-Model-ExifTool

COPYRIGHT & LICENSE

Top


RDF-Redland-Model-ExifTool documentation  | view source Contained in the RDF-Redland-Model-ExifTool distribution.