cpp在图片中写入exif信息 示例
时间: 2023-05-17 16:03:04 浏览: 204
代码如下:
```cpp
#include <iostream>
#include <fstream>
#include <exiv2/exiv2.hpp>
int main(int argc, char** argv) {
if (argc != 3) {
std::cerr << "Usage: " << argv[0] << " image_file exif_file" << std::endl;
return 1;
}
try {
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(argv[1]);
image->readMetadata();
Exiv2::ExifData exifData;
std::ifstream exifFile(argv[2]);
exifFile >> exifData;
image->setExifData(exifData);
image->writeMetadata();
} catch (const std::exception& e) {
std::cerr << "Error: " << e.what() << std::endl;
return 1;
}
return 0;
}
```
这段代码可以将指定图片中的exif信息替换为指定的exif文件中的信息。
阅读全文