1 /* ============================================================
3 * This file is a part of kipi-plugins project
4 * http://www.kipi-plugins.org
7 * Description : a command line tool to convert RAW file to PNG
9 * Copyright (C) 2008 by Gilles Caulier <caulier dot gilles at gmail dot com>
11 * This program is free software; you can redistribute it
12 * and/or modify it under the terms of the GNU General
13 * Public License as published by the Free Software Foundation;
14 * either version 2, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * ============================================================ */
27 #include <qfileinfo.h>
31 #include "kdeversion.h"
33 #if KDE_IS_VERSION(4,0,0)
35 #define PRINT_DEBUG qDebug()
39 #define PRINT_DEBUG kdDebug()
47 using namespace KDcrawIface
;
49 int main (int argc
, char **argv
)
53 PRINT_DEBUG
<< "raw2png - RAW Camera Image to PNG Converter" ENDL
;
54 PRINT_DEBUG
<< "Usage: <rawfile>" ENDL
;
58 QString
filePath(argv
[1]);
59 QFileInfo
input(filePath
);
60 QString
previewFilePath(input
.baseName() + QString(".preview.png"));
61 QFileInfo
previewOutput(previewFilePath
);
62 QString
halfFilePath(input
.baseName() + QString(".half.png"));
63 QFileInfo
halfOutput(halfFilePath
);
65 DcrawInfoContainer identify
;
67 // -----------------------------------------------------------
69 PRINT_DEBUG
<< "raw2png: Identify RAW image from " << input
.fileName() ENDL
;
72 if (!rawProcessor
.rawFileIdentify(identify
, filePath
))
74 PRINT_DEBUG
<< "raw2png: Idendify RAW image failed. Aborted..." ENDL
;
78 int width
= identify
.imageSize
.width();
79 int height
= identify
.imageSize
.height();
81 PRINT_DEBUG
<< "raw2png: Raw image info:" ENDL
;
82 PRINT_DEBUG
<< "--- Date: " << identify
.dateTime
.toString(Qt::ISODate
) ENDL
;
83 PRINT_DEBUG
<< "--- Make: " << identify
.make ENDL
;
84 PRINT_DEBUG
<< "--- Model: " << identify
.model ENDL
;
85 PRINT_DEBUG
<< "--- Size: " << width
<< "x" << height ENDL
;
86 PRINT_DEBUG
<< "--- Filter: " << identify
.filterPattern ENDL
;
87 PRINT_DEBUG
<< "--- Colors: " << identify
.rawColors ENDL
;
89 // -----------------------------------------------------------
91 PRINT_DEBUG
<< "raw2png: Loading RAW image preview" ENDL
;
93 if (!rawProcessor
.loadDcrawPreview(image
, filePath
))
95 PRINT_DEBUG
<< "raw2png: Loading RAW image preview failed. Aborted..." ENDL
;
99 PRINT_DEBUG
<< "raw2png: Saving preview image to "
100 << previewOutput
.fileName() << " size ("
101 << image
.width() << "x" << image
.height()
103 image
.save(previewFilePath
, "PNG");
105 // -----------------------------------------------------------
107 PRINT_DEBUG
<< "raw2png: Loading half RAW image" ENDL
;
110 if (!rawProcessor
.loadHalfPreview(image
, filePath
))
112 PRINT_DEBUG
<< "raw2png: Loading half RAW image failed. Aborted..." ENDL
;
116 PRINT_DEBUG
<< "raw2png: Saving half image to "
117 << halfOutput
.fileName() << " size ("
118 << image
.width() << "x" << image
.height()
120 image
.save(halfFilePath
, "PNG");