RE: Why? Trying to write jpeg in memory and save to file... ยป memio.cpp
| 1 |
// ***************************************************************** -*- C++ -*-
|
|---|---|
| 2 |
// memIo.cpp, $Rev$
|
| 3 |
// Sample program to print the Exif metadata of an image
|
| 4 |
|
| 5 |
#include <exiv2/exiv2.hpp>
|
| 6 |
#include <iostream>
|
| 7 |
#include <cassert>
|
| 8 |
|
| 9 |
int main(int argc, char* const argv[]) |
| 10 |
try { |
| 11 |
|
| 12 |
if (argc != 2) { |
| 13 |
std::cout << "Usage: " << argv[0] << " file\n"; |
| 14 |
return 1; |
| 15 |
}
|
| 16 |
|
| 17 |
Exiv2::DataBuf buf = Exiv2::readFile(argv[1]); |
| 18 |
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(buf.pData_, buf.size_); |
| 19 |
image->readMetadata(); |
| 20 |
Exiv2::ExifData &exifData = image->exifData(); |
| 21 |
exifData["Exif.Image.Model"] = "A long model name to make the Exif metadata grow"; |
| 22 |
image->writeMetadata(); |
| 23 |
Exiv2::FileIo file(argv[1]); |
| 24 |
file.open(); |
| 25 |
file.write(image->io()); |
| 26 |
|
| 27 |
return 0; |
| 28 |
}
|
| 29 |
catch (Exiv2::Error& e) { |
| 30 |
std::cout << "Caught Exiv2 exception '" << e.what() << "'\n"; |
| 31 |
return -1; |
| 32 |
}
|