~ubuntu-branches/debian/lenny/exiv2/lenny

« back to all changes in this revision

Viewing changes to src/iptceasy.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Mark Purcell
  • Date: 2008-06-21 08:23:53 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20080621082353-b1n4w08trwfwbfl4
Tags: 0.17.1-1
* New upstream release
  - Library transition cleared on debian-release/ d-d-a
* Version 0.17 also fixes:
  - CVE-2008-2696: DoS via metadata in images (Closes: #486328)
  - crashes when fed with wrong file (Closes: #485670)
* Urgency medium for CVE fix
* debian/patches/gcc4.3.diff unecessary for gcc-4.3
* Add /usr/share/bug/exiv2/presubj message for reportbug(1)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// ***************************************************************** -*- C++ -*-
2
 
// iptceasy.cpp, $Rev: 560 $
3
 
// The quickest way to access, set or modify Iptc metadata.
4
 
 
5
 
#include "iptc.hpp"
6
 
#include "image.hpp"
7
 
#include <iostream>
8
 
#include <iomanip>
9
 
#include <cassert>
10
 
 
11
 
int main(int argc, char* const argv[])
12
 
try {
13
 
    if (argc != 2) {
14
 
        std::cout << "Usage: " << argv[0] << " file\n";
15
 
        return 1;
16
 
    }
17
 
    std::string file(argv[1]);
18
 
 
19
 
    Exiv2::IptcData iptcData;
20
 
 
21
 
    iptcData["Iptc.Application2.Headline"] = "The headline I am";
22
 
    iptcData["Iptc.Application2.Keywords"] = "Yet another keyword";
23
 
    iptcData["Iptc.Application2.DateCreated"] = "2004-8-3";
24
 
    iptcData["Iptc.Application2.Urgency"] = uint16_t(1);
25
 
    iptcData["Iptc.Envelope.ModelVersion"] = 42;
26
 
    iptcData["Iptc.Envelope.TimeSent"] = "14:41:0-05:00";
27
 
    iptcData["Iptc.Application2.RasterizedCaption"] = "230 42 34 2 90 84 23 146";
28
 
    iptcData["Iptc.0x0009.0x0001"] = "Who am I?";
29
 
 
30
 
    Exiv2::StringValue value;
31
 
    value.read("very!");
32
 
    iptcData["Iptc.Application2.Urgency"] = value;
33
 
 
34
 
    std::cout << "Time sent: " << iptcData["Iptc.Envelope.TimeSent"] << "\n";
35
 
 
36
 
    // Open image file
37
 
    Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(file);
38
 
    assert (image.get() != 0);
39
 
 
40
 
    // Set Iptc data and write it to the file
41
 
    image->setIptcData(iptcData);
42
 
    image->writeMetadata();
43
 
 
44
 
    return 0;
45
 
}
46
 
catch (Exiv2::AnyError& e) {
47
 
    std::cout << "Caught Exiv2 exception '" << e << "'\n";
48
 
    return -1;
49
 
}