Advertisement
Guest User

Untitled

a guest
Sep 27th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.40 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdio.h>
  3. #include <exiv2/exiv2.hpp>
  4.  
  5. #include <iomanip>
  6. #include <cassert>
  7.  
  8. int main(int argc, char const *argv[])
  9. try
  10. {
  11.   if (argc != 2)
  12.   {
  13.     std::cout << "Usage: "<< argv[0] << "file\n";
  14.     return 1;
  15.   }
  16.   std::string file(argv[1]);
  17.   Exiv2::ExifData exifData;
  18.  
  19.   // General Camera Info //
  20.   exifData["Exif.Image.Model"] = "Manta G917L";
  21.   exifData["Exif.Image.Make"]  = "Allied Vision";
  22.  
  23.   // GPS Tag Info //
  24.   exifData["Exif.GPSInfo.GPSVersionID"] = "2 2 2 2";            // Byte
  25.   exifData["Exif.GPSInfo.GPSLatitudeRef"] = "N";                // Ascii
  26.   exifData["Exif.GPSInfo.GPSLatitude"] = "24/1 24/1 24/1";      // Rational
  27.   exifData["Exif.GPSInfo.GPSLongitudeRef"] = "E";               // Ascii
  28.   exifData["Exif.GPSInfo.GPSLongitude"] = "243/1 24/1 24/1";    // Rational
  29.   exifData["Exif.GPSInfo.GPSAltitudeRef"] = "1";                // Byte
  30.   exifData["Exif.GPSInfo.GPSAltitude"] = "23/1";                // Rational
  31.   exifData["Exif.GPSInfo.GPSDateStamp"] = "2016:11:11";         // Ascii
  32.   exifData["Exif.GPSInfo.GPSTimeStamp"] = "23/1 45/1 44/1";     // Rational
  33.  
  34.   Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(file);
  35.   assert(image.get() != 0);
  36.  
  37.   image->setExifData(exifData);
  38.   image->writeMetadata();
  39.   return 0;
  40. }
  41. catch(Exiv2::AnyError& e)
  42. {
  43.   std::cout << "Caught Exiv2 exception '" << e << "'\n";
  44.   return -1;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement