Lesson 1: Reading Meta Data

A Simple Example

Smart Tag Names

In the example above we use photo['DateTimeOriginal'] to
get the value for the time the photo was taken. But tag names are not case
sensitive and additional underlines are also irrelevant. So following
expressions are equivalent:

The Exiftool command-line application has an option (-n) to get values as
numbers if possible, in MiniExiftool you can do this with setting the
:numerical option to true while generating a new instance
with new or using the numerical=-method combining with calling
reload.

This behaviour can be useful if you want to do calculations on the value,
if you only want to show the value the standard behaviour is maybe better.

The Time class of Ruby cannot handle timestamps before 1st January 1970 on
some platforms. If there are timestamps in files before this date it will
result in an error. In this case we can set the option :timestamps
to DateTime to use DateTime objects instead of Time objects.

There is another option :composite. If this is set to
false the composite tags are not calculated by the exiftool
command-line application (option -e).

Further Example

For understanding reading access to meta data also have a look at the
example file print_portraits.rb in the examples
directory.

Lesson 2: Writing Meta Data

Also A Very Simple Example

Save Is Atomar

If you have changed serval values and call the save-method either
all changes will be written to the file or nothing. The return value of the
save-method is true if all values are written to the file
otherwise save returns false. In the last case you can use the
errors-method which returns a hash of the tags which values
couldn't be writed with an error message for each of them.

Interesting Methods

Have a look at the changed?-method for checking if the value of a
specific tag is changed or a changing in general is done. In the same way
the revert-method reverts the value of a specific tag or in
general all changes.