效果
源码
#include <iostream>
#include <iomanip>
#include <cassert>
#include "exiv2/exiv2.hpp"
int main2()
{
const char imagePath[] = "./test.jpeg";
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(imagePath);
assert(image.get() != 0);
image->readMetadata();
Exiv2::ExifData &exifData = image->exifData();
if (exifData.empty()) { return -1; }
// *************************************************************************
// 删除exif信息
// 从Exif数据容器中删除元数据
// 删除迭代器位置的元数据
Exiv2::ExifKey key = Exiv2::ExifKey("Exif.GPSInfo.GPSLongitude");
Exiv2::ExifData::iterator pos = exifData.findKey(key);
if (pos != exifData.end())
{
exifData.erase(pos);
std::cout << "Deleted key \"" << key << "\"\n";
}
else { std::cout << "Key not found"; }
// *************************************************************************
image->setExifData(exifData);
image->writeMetadata();
system("pause");
return 0;
}
关注
笔者 - jxd