| RDF-Redland-Model-ExifTool documentation | view source | Contained in the RDF-Redland-Model-ExifTool distribution. |
RDF::Redland::Model::ExifTool - extends RDF model to read Exif meta data
Using ExifTool and Redland RDF Libraries.
Version 0.15
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.
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.
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
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.
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.
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:
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.
Returns copy of this RDF model's Configuration.
Returns copy of this RDF model's Configuration as string.
Replaces this RDF model's Configuration.
Returns empty list if configuration replaced or list of error strings.
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.
Andrew Flint, <arnhemcr at cpan.org>
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.
You can find documentation for this class with the perldoc command.
perldoc RDF::Redland::Model::ExifTool
You can also look for information at:
http://rt.cpan.org/NoAuth/Bugs.html?Dist=RDF-Redland-Model-ExifTool
Copyright 2008-2010 Andrew Flint, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| RDF-Redland-Model-ExifTool documentation | view source | Contained in the RDF-Redland-Model-ExifTool distribution. |