[Digikam-devel] KDE/kdegraphics/libs/libkexiv2/libkexiv2
Gilles Caulier
caulier.gilles at gmail.com
Wed Jul 2 10:05:14 BST 2008
SVN commit 827085 by cgilles:
libkexiv2 from trunk : do not break tiff image data when whole Exif metadata are written using Exiv2 0.18
CCMAIL: digikam-devel at kde.org
M +36 -1 kexiv2.cpp
--- trunk/KDE/kdegraphics/libs/libkexiv2/libkexiv2/kexiv2.cpp #827084:827085
@@ -224,7 +224,42 @@
if (!d->exifMetadata.empty() &&
(mode == Exiv2::amWrite || mode == Exiv2::amReadWrite))
{
- image->setExifData(d->exifMetadata);
+ if (image->mimeType() == "image/tiff")
+ {
+ // With tiff image we cannot overwrite whole Exif data as well, because
+ // image data are stored in Exif container. We need to take a care about
+ // to not lost image data.
+ Exiv2::ExifData exif = image->exifData();
+ QStringList untouchedTags;
+ untouchedTags << "Exif.Image.ImageWidth";
+ untouchedTags << "Exif.Image.ImageLength";
+ untouchedTags << "Exif.Image.BitsPerSample";
+ untouchedTags << "Exif.Image.Compression";
+ untouchedTags << "Exif.Image.PhotometricInterpretation";
+ untouchedTags << "Exif.Image.FillOrder";
+ untouchedTags << "Exif.Image.SamplesPerPixel";
+ untouchedTags << "Exif.Image.StripOffsets";
+ untouchedTags << "Exif.Image.RowsPerStrip";
+ untouchedTags << "Exif.Image.StripByteCounts";
+ untouchedTags << "Exif.Image.XResolution";
+ untouchedTags << "Exif.Image.YResolution";
+ untouchedTags << "Exif.Image.PlanarConfiguration";
+ untouchedTags << "Exif.Image.ResolutionUnit";
+
+ for (Exiv2::ExifData::iterator it = d->exifMetadata.begin(); it != d->exifMetadata.end(); ++it)
+ {
+ if (!untouchedTags.contains(it->key().c_str()))
+ {
+ exif[it->key().c_str()] = d->exifMetadata[it->key().c_str()];
+ }
+ }
+
+ image->setExifData(exif);
+ }
+ else
+ {
+ image->setExifData(d->exifMetadata);
+ }
}
// Iptc metadata ----------------------------------
More information about the Digikam-devel
mailing list