UseCases
Use Cases
Use cases for metadata parsing in F-Spot (to provide current features):
The code samples below assume the following:
var file = File.Create (full_filename) as Image.File;
This page is somewhat unofficial documentation too.
Reading Metadata
There are two ways to fetch metadata: by reading it from the formats directly (which is hard) and through the combined API, which hides all the nasty details and should be fine for 95% of the uses.
Image size
Image size is not a metadata property per se. It can be found in the Properties.
int height = file.Properties.PhotoHeight;
int width = file.Properties.PhotoWidth;
Image quality
For file types that support it (currently JPEG), the image quality can be guessed (this is the compression value). This can be found in the properties too. How to interpret this value depends on the format of the image.
int quality = file.Properties.PhotoQuality;
Basic photo information
You can retrieve basic photo information by using the members of the ImageTag. This is a convenience API which hides all the format details and automatically selects the best match. Use this whenever possible.
string[] keywords = file.ImageTag.Keywords;
uint rating = file.ImageTag.Rating;
DateTime taken = file.ImageTag.DateTime;
ImageOrientation orientation = file.ImageTag.Orientation;
double exposure = file.ImageTag.ExposureTime;
// etc.
These members are all defined in ImageTag.
Undocumented
- tags, rating at import (XMP)
- comment, date at import (from both Exif and XMP)
- list all metadata (MetadataDisplay) to the user (requires an enumeration through metadata and a ‘title’ for each tag to display to the user together with the value)
Modifying Metadata
- comment, date (Exif and XMP)
- tags, rating (XMP)
- image size (resizing, crop) (Exif)
- orientation (Exif)
Copying Metadata
- copying whole metadata at creating new versions/files (e.g. from a RAW file to a JPEG file) (need to provide Exif, XMP, IPTC)
- clear all metadata from file for export and optionally write some basic information back (e.g. like tags, comment, creator)
File handling
- Read and write sidecar metadata (.xmp files): This is XMP metadata which is written to a separate file and thus not embedded in the file itself.
(Since taglib only gets a file abstraction, it is not possible to reason about other files with the same basename. So two tasks have to be done for this. (1) sidecar files have to be passed to taglib by f-spot and f-spot has to keep the basenames of image and sidecar file in sync. (2) taglib has to accept sidecar files in addition to the metadata stored in the file itself.)
Code Samples
Enumerate Metadata
Enumeration of all metdata is necessary to display it to the user. It is not required to change the metadat at this point. The following code is a API-proposal and not implemented yet and not necessarily the final API.
File file = File.Create (path);
foreach (ImageTag tag in file.ImageTags) {
WriteLine ("Values of Tag: {0}", tag.Title);
foreach (var value in tag) {
WriteLine ("{0} {1}" value.Title, value.Value);
}
}
The challenge is to get an translated title for each value. this can be done in taglib, but it would require translators.

