Exif deletes too many tags??
Added by G K about 9 years ago
Hello,
my example code uses the test.jpg from exiv2-0.23/msvc/test.jpg
If i try to delete the key "Exif.Image.Make", it will delete about 100 exif entries. This does not happen with another exif key!
image->readMetadata();
Exiv2::ExifData &exifData = image->exifData();
Exiv2::IptcData &iptcData = image->iptcData();
Exiv2::XmpData &xmpData = image->xmpData();
fprintf(stdout,"exif key %s\n", key.c_str());
fprintf(stdout,"exif type %s\n", metaType.c_str());
fprintf(stdout,"exif c1 %s\n", ToString(exifData.count()).c_str());fflush(stdout);
if (metaType == "exif") {
    Exiv2::ExifKey exifKey = Exiv2::ExifKey(key);
    Exiv2::ExifData::iterator pos = exifData.findKey(exifKey);
    if (pos  exifData.end()) {
        fprintf(stdout,"Exif Key not found");
    }
    exifData.erase(pos);        
} else if (metaType  "iptc") {
    Exiv2::IptcKey iptcKey = Exiv2::IptcKey(key);
    Exiv2::IptcData::iterator pos = iptcData.findKey(iptcKey);
    if (pos  iptcData.end()) {
        fprintf(stdout,"Iptc Key not found");
    }
        iptcData.erase(pos);    
}if (metaType  "xmp") {
    Exiv2::XmpKey xmpKey = Exiv2::XmpKey(key);
    Exiv2::XmpData::iterator pos = xmpData.findKey(xmpKey);
    if (pos == xmpData.end()) {
        fprintf(stdout,"Xmp Key not found");
    }
    xmpData.erase(pos);
}
fprintf(stdout,"exif c2 %s\n", ToString(exifData.count()).c_str());fflush(stdout);
image->setExifData(exifData);        
image->setIptcData(iptcData);
image->setXmpData(xmpData);    
image->writeMetadata();
image->readMetadata();
Exiv2::ExifData &exifData3 = image->exifData();    
fprintf(stdout,"exif c22 %s\n", ToString(exifData3.count()).c_str());fflush(stdout);
The output in std::out is:
exif key Exif.Image.Make
exif type exif
exif c1 155
exif c2 154
exif c22 49
Replies (2)
RE: Exif deletes too many tags?? - Added by Robin Mills about 9 years ago
Thank you for reporting this. This is an amazing find!
The issue can be reproduced with the exiv2 command-line program. It has been logged as a bug and assigned to me. Issue: 866 http://dev.exiv2.org/issues/866