~ubuntu-branches/ubuntu/precise/exiv2/precise

« back to all changes in this revision

Viewing changes to src/actions.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Mercatante
  • Date: 2006-12-07 18:40:10 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20061207184010-0ouu8v0dr8nznob9
Tags: 0.12-0ubuntu1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 */
21
21
/*
22
22
  File:      actions.cpp
23
 
  Version:   $Rev: 808 $
 
23
  Version:   $Rev: 983 $
24
24
  Author(s): Andreas Huggel (ahu) <ahuggel@gmx.net>
25
25
  History:   08-Dec-03, ahu: created
26
26
             30-Apr-06, Roger Larsson: Print filename if processing multiple files
27
27
 */
28
28
// *****************************************************************************
29
29
#include "rcsid.hpp"
30
 
EXIV2_RCSID("@(#) $Id: actions.cpp 808 2006-06-01 15:09:39Z ahuggel $");
 
30
EXIV2_RCSID("@(#) $Id: actions.cpp 983 2006-11-16 14:42:38Z ahuggel $")
31
31
 
32
32
// *****************************************************************************
33
33
// included header files
37
37
# include "exv_conf.h"
38
38
#endif
39
39
 
 
40
#ifndef EXV_HAVE_TIMEGM
 
41
# include "timegm.h"
 
42
#endif
40
43
#include "actions.hpp"
 
44
#include "exiv2.hpp"
41
45
#include "image.hpp"
42
46
#include "jpgimage.hpp"
43
 
#include "exiv2.hpp"
44
47
#include "utils.hpp"
45
48
#include "types.hpp"
46
49
#include "exif.hpp"
47
50
#include "canonmn.hpp"
48
51
#include "iptc.hpp"
49
52
#include "futils.hpp"
50
 
#ifndef EXV_HAVE_TIMEGM
51
 
# include "timegm.h"
52
 
#endif
53
53
 
54
54
// + standard includes
55
55
#include <string>
287
287
        done = false;
288
288
        printLabel("Flash bias");
289
289
        if (!done) {
290
 
            done = 0 != printTag(exifData, "Exif.CanonCs2.FlashBias");
 
290
            done = 0 != printTag(exifData, "Exif.CanonSi.FlashBias");
291
291
        }
292
292
        if (!done) {
293
293
            done = 0 != printTag(exifData, "Exif.Panasonic.FlashBias");
317
317
            done = 0 != printTag(exifData, "Exif.Photo.SubjectDistance");
318
318
        }
319
319
        if (!done) {
320
 
            done = 0 != printTag(exifData, "Exif.CanonCs2.SubjectDistance");
 
320
            done = 0 != printTag(exifData, "Exif.CanonSi.SubjectDistance");
321
321
        }
322
322
        std::cout << std::endl;
323
323
 
329
329
            done = 0 != printTag(exifData, "Exif.Photo.ISOSpeedRatings");
330
330
        }
331
331
        if (!done) {
332
 
            done = 0 != printTag(exifData, "Exif.CanonCs2.ISOSpeed");
 
332
            done = 0 != printTag(exifData, "Exif.CanonSi.ISOSpeed");
333
333
        }
334
334
        if (!done) {
335
335
            done = 0 != printTag(exifData, "Exif.Nikon1.ISOSpeed");
362
362
            done = 0 != printTag(exifData, "Exif.Photo.ExposureProgram");
363
363
        }
364
364
        if (!done) {
365
 
            done = 0 != printTag(exifData, "Exif.CanonCs1.ExposureProgram");
 
365
            done = 0 != printTag(exifData, "Exif.CanonCs.ExposureProgram");
366
366
        }
367
367
        if (!done) {
368
368
            done = 0 != printTag(exifData, "Exif.MinoltaCs7D.ExposureMode");
386
386
        printLabel("Macro mode");
387
387
        done = false;
388
388
        if (!done) {
389
 
            done = 0 != printTag(exifData, "Exif.CanonCs1.Macro");
 
389
            done = 0 != printTag(exifData, "Exif.CanonCs.Macro");
390
390
        }
391
391
        if (!done) {
392
392
            done = 0 != printTag(exifData, "Exif.Fujifilm.Macro");
410
410
        printLabel("Image quality");
411
411
        done = false;
412
412
        if (!done) {
413
 
            done = 0 != printTag(exifData, "Exif.CanonCs1.Quality");
 
413
            done = 0 != printTag(exifData, "Exif.CanonCs.Quality");
414
414
        }
415
415
        if (!done) {
416
416
            done = 0 != printTag(exifData, "Exif.Fujifilm.Quality");
478
478
        printLabel("White balance");
479
479
        done = false;
480
480
        if (!done) {
481
 
            done = 0 != printTag(exifData, "Exif.CanonCs2.WhiteBalance");
 
481
            done = 0 != printTag(exifData, "Exif.CanonSi.WhiteBalance");
482
482
        }
483
483
        if (!done) {
484
484
            done = 0 != printTag(exifData, "Exif.Fujifilm.WhiteBalance");
1235
1235
        Exiv2::ExifData &exifData = image_->exifData();
1236
1236
        Exiv2::IptcData &iptcData = image_->iptcData();
1237
1237
        if (modifyCmd.metadataId_ == exif) {
1238
 
            Exiv2::ExifData::iterator pos =
1239
 
                exifData.findKey(Exiv2::ExifKey(modifyCmd.key_));
1240
 
            if (pos != exifData.end()) exifData.erase(pos);
 
1238
            Exiv2::ExifData::iterator pos;
 
1239
            Exiv2::ExifKey exifKey = Exiv2::ExifKey(modifyCmd.key_);
 
1240
            while((pos = exifData.findKey(exifKey)) != exifData.end()) {
 
1241
                exifData.erase(pos);
 
1242
            }
1241
1243
        }
1242
1244
        if (modifyCmd.metadataId_ == iptc) {
1243
 
            Exiv2::IptcData::iterator pos =
1244
 
                iptcData.findKey(Exiv2::IptcKey(modifyCmd.key_));
1245
 
            if (pos != iptcData.end()) iptcData.erase(pos);
 
1245
            Exiv2::IptcData::iterator pos;
 
1246
            Exiv2::IptcKey iptcKey = Exiv2::IptcKey(modifyCmd.key_);
 
1247
            while((pos = iptcData.findKey(iptcKey)) != iptcData.end()) {
 
1248
                iptcData.erase(pos);
 
1249
            }
1246
1250
        }
1247
1251
    }
1248
1252
 
1450
1454
            || timeStr[13] != ':' || timeStr[16] != ':') return 3;
1451
1455
        if (0 == tm) return 4;
1452
1456
        memset(tm, 0x0, sizeof(struct tm));
 
1457
        tm->tm_isdst = -1;
1453
1458
 
1454
1459
        long tmp;
1455
1460
        if (!Util::strtol(timeStr.substr(0,4).c_str(), tmp)) return 5;
1555
1560
    int renameFile(std::string& newPath, const struct tm* tm)
1556
1561
    {
1557
1562
        std::string path = newPath;
 
1563
        std::string format = Params::instance().format_;
 
1564
        Util::replace(format, ":basename:",   Util::basename(path, true));
 
1565
        Util::replace(format, ":dirname:",    Util::basename(Util::dirname(path)));
 
1566
        Util::replace(format, ":parentname:", Util::basename(Util::dirname(Util::dirname(path))));
 
1567
 
1558
1568
        const size_t max = 1024;
1559
1569
        char basename[max];
1560
1570
        memset(basename, 0x0, max);
1561
 
        if (strftime(basename, max, Params::instance().format_.c_str(), tm) == 0) {
 
1571
        if (strftime(basename, max, format.c_str(), tm) == 0) {
1562
1572
            std::cerr << "Filename format yields empty filename for the file "
1563
1573
                      << path << "\n";
1564
1574
            return 1;