int main (int argc, char **argv) { if(argc != 2) { kDebug() << "erasetag - erase tag from from image"; kDebug() << "Usage: <image>"; return -1; } QString filePath(argv[1]); KExiv2 meta; meta.load(filePath); meta.setWriteRawFiles(true); bool b = meta.removeExifTag("Exif.OlympusIp.BlackLevel", false); kDebug() << "Exif.OlympusIp.BlackLevel found = " << b; QByteArray ba = meta.getExifTagData("Exif.OlympusIp.BlackLevel"); kDebug() << "Exif.OlympusIp.BlackLevel removed = " << ba.isEmpty(); if (b) { meta.applyChanges(); } return 0; }
int main (int argc, char **argv) { if (argc != 3) { qDebug() << "Adding a face rectangle to image"; qDebug() << "Usage: <add/remove> <image>"; return -1; } QString filePath(QString::fromLatin1(argv[2])); KExiv2Iface::KExiv2::initializeExiv2(); KExiv2 meta; meta.load(filePath); meta.setWriteRawFiles(true); /** Add a random rectangle with facetag Bob **/ QString name = QString::fromLatin1("Bob Marley"); float x =0.5; float y =0.5; float w = 60; float h = 60; QRectF rect(x,y,w,h); QMap<QString, QRectF> faces; faces[name] = rect; QString name2 = QString::fromLatin1("Hello Kitty!"); QRectF rect2(0.4,0.4,30,30); faces[name2] = rect2; bool g = meta.supportXmp(); qDebug() << "Image support XMP" << g; const QString bag = QString::fromLatin1("Xmp.mwg-rs.Regions/mwg-rs:RegionList"); QString op(QString::fromLatin1(argv[1])); if (op == QString::fromLatin1("add")) setFaceTags(meta,bag.toLatin1().constData(),faces,false); else removeFaceTags(meta,bag.toLatin1().constData()); meta.applyChanges(); QString recoverName = QString::fromLatin1("Xmp.mwg-rs.Regions/mwg-rs:RegionList[1]/mwg-rs:Name"); KExiv2 meta2; meta2.load(filePath); meta2.setWriteRawFiles(true); QString nameR = meta2.getXmpTagString(recoverName.toLatin1().constData(),false); qDebug() << "Saved name is:" << nameR; KExiv2Iface::KExiv2::cleanupExiv2(); return 0; }