[Kde-imaging] Exiv2 interface on trunk and Exif restorer...

Gilles Caulier caulier.gilles at kdemail.net
Tue Sep 19 08:56:08 CEST 2006


Hi all,

If you have follow my recent commits into svn trunk, there is a new common 
class witch provide an interface to Exiv2 library (http://www.exiv2.org).

http://websvn.kde.org/trunk/extragear/libs/kipi-plugins/common/exiv2iface/exiv2iface.cpp?rev=585974&view=auto

This class is based on an internal class from digiKam core to manage metadata. 
With this class we can restore metadata to a converted/transformed image 
using Qt, like ExifRestorer implementation done into all plugins.

But we can do better (:=))

The ExifRestorer can only restore the JPEG Exif section. With the Exiv2 
interface, we can restore Exif, Comments, and IPTC sections. Also, 
ExifRestorer can only extract metadata from JPEG, Exiv2 can do it from All 
RAW files, JPEG, PNG and TIFF/EP !

Actually, Exiv2 library can only write metadata into a JPEG files, but we 
working to support TIFF/EP, PNG and RAW files ! This will very powerfull.

I recommend to all plugins mainteners to update your code to use the common 
Exiv2 interface class instead the ExifRestorer (witch is non-common and 
duplicated into each plugins !)

To use it, just look the plugins witch already support it :JPEGLossLess, 
AdjustTime, and RAWConverter. 

You just need to fix you Makefile.am like this :

INCLUDES     = -I$(top_srcdir)/kipi-plugins/common/exiv2iface ...

kipiplugin_PLUGINNAME_la_LIBADD = 
(top_builddir)/kipi-plugins/common/exiv2iface/libexiv2iface.la ...

And your implementation to remplace ExifRestorer like this :

#include "pluginsversion.h"
#include "exiv2iface.h"
...

// Update the metadata to target file.

QImage img(mypicture);
QImage exifThumbnail = img.scale(160, 120, QImage::ScaleMin);
exiv2Iface.load(mypicture);

// Just to add/update the "Software" Exif/IPTC tags with your plugin name & 
version (if necessary)
exiv2Iface.setImageProgramId(QString("Kipi PLUGINNAME"), 
QString(kipiplugins_version));

// If you have transformed the image, unforget to set the Exif 
dimensions/thumbnail tags properly  (if necessary).
exiv2Iface.setImageDimensions(img.size());
exiv2Iface.setExifThumbnail(exifThumbnail);

// and now save all metadata.
exiv2Iface.save(destGiven);

In the Exiv2 interface, there are other methods to update/extract some 
metadata informations. But the class is not complete, and new methods can be 
added in the future if you need. 

For that, no need to re-invent the wheel : we have a more complete metadata 
class into digiKam core and a backport is very simple. Just ask me what you 
want, i will do it (:=)))

Friendly

Gilles Caulier



More information about the Kde-imaging mailing list