~ubuntu-branches/ubuntu/saucy/digikam/saucy

« back to all changes in this revision

Viewing changes to libs/dimg/filters/lens/testlensfuniface.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2010-10-24 00:20:43 UTC
  • mfrom: (1.2.31 upstream)
  • Revision ID: james.westby@ubuntu.com-20101024002043-y7y9fg4rvxy0obcc
Tags: 2:1.5.0-0ubuntu1
* New upstream release
  - Bump build-dependencies
  - Build against libkipi-dev 1.5.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/** ===========================================================
 
2
 *
 
3
 * This file is a part of digiKam project
 
4
 * <a href="http://www.digikam.org">http://www.digikam.org</a>
 
5
 *
 
6
 * @date   2010-09-15
 
7
 * @brief  a command line tool to parse metadata dedicated to LensFun
 
8
 *
 
9
 * @author Copyright (C) 2010 by Gilles Caulier
 
10
 *         <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a>
 
11
 *
 
12
 * This program is free software; you can redistribute it
 
13
 * and/or modify it under the terms of the GNU General
 
14
 * Public License as published by the Free Software Foundation;
 
15
 * either version 2, or (at your option)
 
16
 * any later version.
 
17
 *
 
18
 * This program is distributed in the hope that it will be useful,
 
19
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
20
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 
21
 * GNU General Public License for more details.
 
22
 *
 
23
 * ============================================================ */
 
24
 
 
25
// Qt includes
 
26
 
 
27
#include <QString>
 
28
#include <QFile>
 
29
 
 
30
// KDE includes.
 
31
 
 
32
#include "kdebug.h"
 
33
 
 
34
// Local includes.
 
35
 
 
36
#include "lensfuniface.h"
 
37
 
 
38
using namespace Digikam;
 
39
 
 
40
int main (int argc, char** argv)
 
41
{
 
42
    if(argc != 2)
 
43
    {
 
44
        kDebug() << "testlensfuniface - test to parse metadata dedicated to LensFun";
 
45
        kDebug() << "Usage: <image>";
 
46
        return -1;
 
47
    }
 
48
 
 
49
    QString filePath(argv[1]);
 
50
 
 
51
    DImg         img(filePath);
 
52
    DMetadata    meta(img.getMetadata());
 
53
    LensFunIface iface;
 
54
    LensFunIface::MetadataMatch ret = iface.findFromMetadata(meta);
 
55
    if (ret == LensFunIface::MetadataExactMatch)
 
56
    {
 
57
        LensFunFilter filter(&img, 0L, iface.settings());
 
58
        filter.startFilterDirectly();
 
59
        img.putImageData(filter.getTargetImage().bits());
 
60
 
 
61
        Digikam::KExiv2Data data = img.getMetadata();
 
62
        filter.registerSettingsToXmp(data);
 
63
        img.setMetadata(data);
 
64
        return img.save("lensfuniface-output.png", "PNG");
 
65
    }
 
66
 
 
67
    return false;
 
68
}