Version: (using KDE KDE 3.5.2) Installed from: Ubuntu Packages After I have update dcraw to 8.21 the RAW convertion fails for digikam 0.8.2-rc1 as well as 0.9.0-svn. If I try to convert a raw file I get the following error at the prompt: KIPI (general): WARNING: ProcessController: stderr: Non-numeric argument to "-r" KIPI (general): KIPI (general): WARNING: ProcessController: stderr: Invalid ppm file read from pipe hth, Marcus.
Look like '-r' dcraw option syntax has changed with this version. This suck roally (:=( There is no options compatibility respected ! I need to investiguate about news 4 values to use with -r. There is no suitable comments in dcraw source code. If you have some informations about, let's me hear... Gilles
only this information from the changelog: 2006-05-14 dcoffin <dcoffin@funky> * dcraw.c: Replaced "-r" and "-l" options with raw white balance. Added "-H 2" option for rudimentary highlight recovery.
SVN commit 583806 by cgilles: kipi-plugins from trunk : Raw Converter : complete rewrite raw converter core ! - Removing old external sub program to invoque dcraw instance. - Using multithreaded implementation based on JPEGLossLess plugin core. - New dcraw interface to invoque dcraw binary program directly using a separate thread. - New dcraw settings widget common to batch and single version of converter. - The new implementation always give RAW file thumbnails in batch converter dialog. - New save target file settings widget common to batch and single version of converter. - New option to convert raw file based on last dcraw version avaialble (8.38) and similar than digiKam dcraw setup : * quality decoding (Bilinear, AHD, VND). * Interpolation as 4 colors. * Use super CCD sensor. * Auto Color balance. * Camera whithe balance. * Noise reduction settings. * Highlight clipping (solid white, Unclip, Recontruct using level) * Brighness adjustements. - Removing obsolete dcraw options comming from dcraw v. 8.xx : red/blue adjustments. - Code simplification and optimisations about compression level with TIFF output files. - Fresh screenshot: http://digikam3rdparty.free.fr/Screenshots/newkipirawconverter.png NOTES : - The code have been tested with the last dcraw release from today. Please take a care if you use an with old version. - The code is in beta. Please take a care. TODO : - Metadata preservation using Exiv2 library. - Embedding sRGB ICC color profile in JPEG/PNG/TIFF files. - More output color space, like Adobe, and WideGamut. - dcraw version detection. - Fix dcraw decoding canceling to stop dcraw imediatly (actually the implementation wait until the current raw file decoding is done). - Fix the dcraw interface class to use bach and single converter plugin at the same time. CCMAIL: kde-imaging@kde.org BUG: 128394 CCBUGS: 107905 M +4 -12 Makefile.am A actions.h [License: GPL] A actionthread.cpp [License: GPL] A actionthread.h [License: GPL] M +323 -348 batchdialog.cpp M +30 -73 batchdialog.h M +3 -2 clistviewitem.h D dcrawprocess.cpp A dcrawsettingswidget.cpp [License: GPL] A dcrawsettingswidget.h [License: GPL] A dcrawutils.cpp [POSSIBLY UNSAFE: popen,scanf] [License: GPL] A dcrawutils.h [License: GPL] D kipidcrawclient.1 A mtqueue.h [License: GPL] D processcontroller.cpp D processcontroller.h A savesettingswidget.cpp [License: GPL] A savesettingswidget.h [License: GPL] M +261 -220 singledialog.cpp M +29 -36 singledialog.h
SVN commit 584176 by cgilles: kipi-plugins from trunk : Raw Converter : dcraw version detection at startup. Code come from digiKam project CCMAIL: kde-imaging@kde.org CCBUGS: 107905, 128394 M +1 -1 Makefile.am A dcrawbinary.cpp [License: GPL] A dcrawbinary.h [License: GPL] M +31 -18 plugin_rawconverter.cpp --- trunk/extragear/libs/kipi-plugins/rawconverter/Makefile.am #584175:584176 @@ -12,7 +12,7 @@ # Srcs for the plugin kipiplugin_rawconverter_la_SOURCES = plugin_rawconverter.cpp dcrawiface.cpp savesettingswidget.cpp \ batchdialog.cpp actionthread.cpp dcrawsettingswidget.cpp \ - singledialog.cpp previewwidget.cpp iccjpeg.c + singledialog.cpp previewwidget.cpp iccjpeg.c dcrawbinary.cpp # Libs needed by the plugin kipiplugin_rawconverter_la_LIBADD = -ljpeg -lpng $(LIB_TIFF) $(LIBKIPI_LIBS) $(LIB_KIO) $(LIB_KDEUI) $(LIB_KDECORE) $(LIB_QT) --- trunk/extragear/libs/kipi-plugins/rawconverter/plugin_rawconverter.cpp #584175:584176 @@ -53,6 +53,7 @@ // Local includes. #include "rawfiles.h" +#include "dcrawbinary.h" #include "singledialog.h" #include "batchdialog.h" #include "plugin_rawconverter.h" @@ -123,30 +124,42 @@ bool Plugin_RawConverter::checkBinaries() { - QProcess process; + KIPIRawConverterPlugin::DcrawBinary dcrawBinary; - process.clearArguments(); - process.addArgument("kipidcrawclient"); - - if (!process.start()) + if (!dcrawBinary.isAvailable()) { - KMessageBox::error(kapp->activeWindow(), i18n("Failed to start raw converter client.\n" - "Please check your installation.")); + KMessageBox::information( + kapp->activeWindow(), + i18n("<qt><p>Unable to find the dcraw executable:<br> " + "This program is required by this plugin to support raw file decoding. " + "Please install dcraw as a package from your distributor " + "or <a href=\"%1\">download the source</a>.</p>" + "<p>Note: at least, dcraw version %2 is required by this plugin.</p></qt>") + .arg("http://www.cybercom.net/~dcoffin/dcraw") + .arg(dcrawBinary.minimalVersion()), + QString::null, + QString::null, + KMessageBox::Notify | KMessageBox::AllowLink); return false; } - process.clearArguments(); - process.addArgument("dcraw"); - - if (!process.start()) + if (!dcrawBinary.versionIsRight()) { - KMessageBox::error(kapp->activeWindow(), - i18n("<qt><p>Unable to find the dcraw executable:<br> " - "This program is required to process Raw file formats conversion. " - "Please install dcraw as a package from your distributor " - "or <a href=\"%2\">download the source</a>.</p></qt>") - .arg("http://www.cybercom.net/~dcoffin/dcraw/")); - + KMessageBox::information( + kapp->activeWindow(), + i18n("<qt><p>dcraw executable isn't up to date:<br> " + "The version %1 of dcraw have been found on your computer. " + "This version is too old to run properlly with this plugin. " + "Please update dcraw as a package from your distributor " + "or <a href=\"%2\">download the source</a>.</p>" + "<p>Note: at least, dcraw version %3 is required by this " + "plugin</p></qt>") + .arg(dcrawBinary.version()) + .arg("http://www.cybercom.net/~dcoffin/dcraw") + .arg(dcrawBinary.minimalVersion()), + QString::null, + QString::null, + KMessageBox::Notify | KMessageBox::AllowLink); return false; }
SVN commit 584185 by cgilles: kipi-plugins from trunk : Raw Converter : print dcraw version detected at startup to the header of RAW decoding settings area. CCMAIL: kde-imaging@kde.org CCBUGS: 107905, 128394 M +2 -2 batchdialog.cpp M +1 -1 batchdialog.h M +4 -2 dcrawsettingswidget.cpp M +1 -1 dcrawsettingswidget.h M +10 -6 plugin_rawconverter.cpp M +1 -1 plugin_rawconverter.h M +2 -2 singledialog.cpp M +1 -1 singledialog.h --- trunk/extragear/libs/kipi-plugins/rawconverter/batchdialog.cpp #584184:584185 @@ -74,7 +74,7 @@ namespace KIPIRawConverterPlugin { -BatchDialog::BatchDialog(QWidget* /*parent*/) +BatchDialog::BatchDialog(QWidget* /*parent*/, const QString& dcrawVersion) : KDialogBase(0, 0, false, i18n("Raw Images Batch Converter"), Help|User1|User2|Close, Close, true, i18n("Con&vert"), i18n("&Abort")) @@ -125,7 +125,7 @@ // --------------------------------------------------------------- - m_decodingSettingsBox = new DcrawSettingsWidget(m_page); + m_decodingSettingsBox = new DcrawSettingsWidget(m_page, dcrawVersion); m_saveSettingsBox = new SaveSettingsWidget(m_page); mainLayout->addMultiCellWidget(m_decodingSettingsBox, 1, 1, 1, 1); --- trunk/extragear/libs/kipi-plugins/rawconverter/batchdialog.h #584184:584185 @@ -55,7 +55,7 @@ public: - BatchDialog(QWidget *parent); + BatchDialog(QWidget *parent, const QString& dcrawVersion); ~BatchDialog(); void addItems(const QStringList& itemList); --- trunk/extragear/libs/kipi-plugins/rawconverter/dcrawsettingswidget.cpp #584184:584185 @@ -93,8 +93,10 @@ KDoubleNumInput *NRSigmaRange; }; -DcrawSettingsWidget::DcrawSettingsWidget(QWidget *parent) - : QGroupBox(0, Qt::Vertical, i18n("RAW Decoding Settings"), parent) +DcrawSettingsWidget::DcrawSettingsWidget(QWidget *parent, const QString& dcrawVersion) + : QGroupBox(0, Qt::Vertical, + i18n("RAW Decoding Settings (dcraw %1)").arg(dcrawVersion), + parent) { d = new DcrawSettingsWidgetPriv; QGridLayout* settingsBoxLayout = new QGridLayout(layout(), 10, 1, KDialog::spacingHint()); --- trunk/extragear/libs/kipi-plugins/rawconverter/dcrawsettingswidget.h #584184:584185 @@ -40,7 +40,7 @@ public: - DcrawSettingsWidget(QWidget *parent); + DcrawSettingsWidget(QWidget *parent, const QString& dcrawVersion); ~DcrawSettingsWidget(); bool useCameraWB(); --- trunk/extragear/libs/kipi-plugins/rawconverter/plugin_rawconverter.cpp #584184:584185 @@ -122,9 +122,10 @@ return false; } -bool Plugin_RawConverter::checkBinaries() +bool Plugin_RawConverter::checkBinaries(QString &dcrawVersion) { KIPIRawConverterPlugin::DcrawBinary dcrawBinary; + dcrawVersion = dcrawBinary.version(); if (!dcrawBinary.isAvailable()) { @@ -154,7 +155,7 @@ "or <a href=\"%2\">download the source</a>.</p>" "<p>Note: at least, dcraw version %3 is required by this " "plugin</p></qt>") - .arg(dcrawBinary.version()) + .arg(dcrawVersion) .arg("http://www.cybercom.net/~dcoffin/dcraw") .arg(dcrawBinary.minimalVersion()), QString::null, @@ -182,7 +183,8 @@ if ( !images.isValid() ) return; - if (!checkBinaries()) + QString dcrawVersion; + if (!checkBinaries(dcrawVersion)) return; if (!isRAWFile(images.images()[0].path())) @@ -193,7 +195,8 @@ } KIPIRawConverterPlugin::SingleDialog *converter = - new KIPIRawConverterPlugin::SingleDialog(images.images()[0].path(), kapp->activeWindow()); + new KIPIRawConverterPlugin::SingleDialog(images.images()[0].path(), + kapp->activeWindow(), dcrawVersion); converter->show(); } @@ -214,11 +217,12 @@ if ( !images.isValid() ) return; - if (!checkBinaries()) + QString dcrawVersion; + if (!checkBinaries(dcrawVersion)) return; KIPIRawConverterPlugin::BatchDialog *converter = - new KIPIRawConverterPlugin::BatchDialog(kapp->activeWindow()); + new KIPIRawConverterPlugin::BatchDialog(kapp->activeWindow(), dcrawVersion); KURL::List urls = images.images(); QStringList files; --- trunk/extragear/libs/kipi-plugins/rawconverter/plugin_rawconverter.h #584184:584185 @@ -46,7 +46,7 @@ private: - bool checkBinaries(); + bool checkBinaries(QString &dcrawVersion); bool isRAWFile(const QString& filePath); private slots: --- trunk/extragear/libs/kipi-plugins/rawconverter/singledialog.cpp #584184:584185 @@ -65,7 +65,7 @@ namespace KIPIRawConverterPlugin { -SingleDialog::SingleDialog(const QString& file, QWidget *parent) +SingleDialog::SingleDialog(const QString& file, QWidget *parent, const QString& dcrawVersion) : KDialogBase(parent, 0, false, i18n("Raw Image Converter"), Help|User1|User2|User3|Close, Close, true, i18n("&Preview"), i18n("Con&vert"), i18n("&Abort")) @@ -115,7 +115,7 @@ // --------------------------------------------------------------- - m_decodingSettingsBox = new DcrawSettingsWidget(page); + m_decodingSettingsBox = new DcrawSettingsWidget(page, dcrawVersion); m_saveSettingsBox = new SaveSettingsWidget(page); mainLayout->addMultiCellWidget(m_decodingSettingsBox, 1, 1, 1, 1); --- trunk/extragear/libs/kipi-plugins/rawconverter/singledialog.h #584184:584185 @@ -49,7 +49,7 @@ public: - SingleDialog(const QString& file, QWidget *parent); + SingleDialog(const QString& file, QWidget *parent, const QString& dcrawVersion); ~SingleDialog(); protected:
SVN commit 584218 by cgilles: kipi-plugins from trunk : Raw Converter : add 'Default' button to set all settings to default values. CCMAIL: kde-imaging@kde.org CCBUGS: 107905, 128394 M +11 -5 batchdialog.cpp M +1 -0 batchdialog.h M +15 -0 dcrawsettingswidget.cpp M +2 -0 dcrawsettingswidget.h M +6 -0 savesettingswidget.cpp M +2 -0 savesettingswidget.h M +11 -5 singledialog.cpp M +4 -3 singledialog.h --- trunk/extragear/libs/kipi-plugins/rawconverter/batchdialog.cpp #584217:584218 @@ -76,7 +76,7 @@ BatchDialog::BatchDialog(QWidget* /*parent*/, const QString& dcrawVersion) : KDialogBase(0, 0, false, i18n("Raw Images Batch Converter"), - Help|User1|User2|Close, Close, true, + Help|Default|User1|User2|Close, Close, true, i18n("Con&vert"), i18n("&Abort")) { m_currentConvertItem = 0; @@ -214,6 +214,12 @@ KDialogBase::slotClose(); } +void BatchDialog::slotDefault() +{ + m_decodingSettingsBox->setDefaultSettings(); + m_saveSettingsBox->setDefaultSettings(); +} + void BatchDialog::readSettings() { KConfig config("kipirc"); @@ -233,6 +239,10 @@ (RawDecodingSettings::DecodingQuality)config.readNumEntry("Decoding Quality", (int)(RawDecodingSettings::BILINEAR))); + m_decodingSettingsBox->setOutputColorSpace( + (RawDecodingSettings::OutputColorSpace)config.readNumEntry("Output Color Space", + (int)(RawDecodingSettings::SRGB))); + m_saveSettingsBox->setFileFormat( (RawDecodingSettings::OutputFormat)config.readNumEntry("Output Format", (int)(RawDecodingSettings::PNG))); @@ -241,10 +251,6 @@ (SaveSettingsWidget::ConflictRule)config.readNumEntry("Conflict", (int)(SaveSettingsWidget::OVERWRITE))); - m_decodingSettingsBox->setOutputColorSpace( - (RawDecodingSettings::OutputColorSpace)config.readNumEntry("Output Color Space", - (int)(RawDecodingSettings::SRGB))); - resize(configDialogSize(config, QString("Batch Raw Converter Dialog"))); } --- trunk/extragear/libs/kipi-plugins/rawconverter/batchdialog.h #584217:584218 @@ -79,6 +79,7 @@ private slots: + void slotDefault(); void slotClose(); void slotHelp(); void slotUser1(); --- trunk/extragear/libs/kipi-plugins/rawconverter/dcrawsettingswidget.cpp #584217:584218 @@ -285,6 +285,21 @@ delete d; } +void DcrawSettingsWidget::setDefaultSettings() +{ + setCameraWB(true); + setAutoColorBalance(true); + setFourColor(false); + setUnclipColor(0); + setSecondarySensor(false); + setNoiseReduction(false); + setBrightness(1.0); + setSigmaDomain(2.0); + setSigmaRange(4.0); + setQuality(RawDecodingSettings::BILINEAR); + setOutputColorSpace(RawDecodingSettings::SRGB); +} + void DcrawSettingsWidget::slotUnclipColorActivated(int v) { if (v == 2) // Reconstruct Highlight method --- trunk/extragear/libs/kipi-plugins/rawconverter/dcrawsettingswidget.h #584217:584218 @@ -67,6 +67,8 @@ void setQuality(RawDecodingSettings::DecodingQuality q); void setOutputColorSpace(RawDecodingSettings::OutputColorSpace c); + void setDefaultSettings(); + private slots: void slotUnclipColorActivated(int); --- trunk/extragear/libs/kipi-plugins/rawconverter/savesettingswidget.cpp #584217:584218 @@ -121,6 +121,12 @@ delete d; } +void SaveSettingsWidget::setDefaultSettings() +{ + setFileFormat(RawDecodingSettings::PNG); + setConflictRule(SaveSettingsWidget::OVERWRITE); +} + RawDecodingSettings::OutputFormat SaveSettingsWidget::fileFormat() { return(RawDecodingSettings::OutputFormat)(d->formatComboBox->currentItem()); --- trunk/extragear/libs/kipi-plugins/rawconverter/savesettingswidget.h #584217:584218 @@ -57,6 +57,8 @@ void setFileFormat(RawDecodingSettings::OutputFormat f); void setConflictRule(ConflictRule r); + void setDefaultSettings(); + signals: void signalSaveFormatChanged(); --- trunk/extragear/libs/kipi-plugins/rawconverter/singledialog.cpp #584217:584218 @@ -67,7 +67,7 @@ SingleDialog::SingleDialog(const QString& file, QWidget *parent, const QString& dcrawVersion) : KDialogBase(parent, 0, false, i18n("Raw Image Converter"), - Help|User1|User2|User3|Close, Close, true, + Help|Default|User1|User2|User3|Close, Close, true, i18n("&Preview"), i18n("Con&vert"), i18n("&Abort")) { m_inputFile = file; @@ -208,6 +208,12 @@ KDialogBase::slotClose(); } +void SingleDialog::slotDefault() +{ + m_decodingSettingsBox->setDefaultSettings(); + m_saveSettingsBox->setDefaultSettings(); +} + void SingleDialog::readSettings() { KConfig config("kipirc"); @@ -227,6 +233,10 @@ (RawDecodingSettings::DecodingQuality)config.readNumEntry("Decoding Quality", (int)(RawDecodingSettings::BILINEAR))); + m_decodingSettingsBox->setOutputColorSpace( + (RawDecodingSettings::OutputColorSpace)config.readNumEntry("Output Color Space", + (int)(RawDecodingSettings::SRGB))); + m_saveSettingsBox->setFileFormat( (RawDecodingSettings::OutputFormat)config.readNumEntry("Output Format", (int)(RawDecodingSettings::PNG))); @@ -235,10 +245,6 @@ (SaveSettingsWidget::ConflictRule)config.readNumEntry("Conflict", (int)(SaveSettingsWidget::OVERWRITE))); - m_decodingSettingsBox->setOutputColorSpace( - (RawDecodingSettings::OutputColorSpace)config.readNumEntry("Output Color Space", - (int)(RawDecodingSettings::SRGB))); - resize(configDialogSize(config, QString("Single Raw Converter Dialog"))); } --- trunk/extragear/libs/kipi-plugins/rawconverter/singledialog.h #584217:584218 @@ -75,13 +75,14 @@ void processingFailed(const QString&); private slots: - + + void slotDefault(); + void slotClose(); void slotHelp(); void slotUser1(); void slotUser2(); void slotUser3(); - void slotClose(); - + void slotIdentify(); void slotPreviewBlinkTimerDone();
SVN commit 584591 by cgilles: kipi-plugins from trunk : Raw Converter : full cancelable (when you want) dcraw instance during RAW image data decoding. The code use now a KProcess instance instead a simple non-cancelable popen() call. The implementation is inspired from digiKam RAW image loader CCBUGS: 107905, 128394 M +1 -1 dcrawbinary.h M +357 -166 dcrawiface.cpp M +35 -12 dcrawiface.h M +7 -1 rawdecodingsettings.h M +2 -2 singledialog.cpp
SVN commit 584763 by cgilles: kipi-plugins from trunk : Raw Converter : Exif/makernotes/iptc/gps metadata restoration after RAW image decoding. - Add Exiv2 depency. I recommend to use the current implementation of Exiv2 from svn (Exiv2 0.11 will be release in a near future) - Add a new Exiv2 interface class based on some part of digiKam core. This class will be will be moved later to the common plugins folder to remplace libkexif depency everywhere. I need to polish and improve the code before. - Actually, 2 output file formats are fully supported to store metadata : JPEG and PNG. Note PNG Exif/Iptc storing use ImageMagick raw profile stored in compressed text chunk. Tiff file format will be added when Exiv2 library will support Tiff write io (normally later 0.11 release) To all digiKam users : after to have converted Raw files using this plugin, you will have the pleasure to see all metadata into target files using Metadata side bar (:=))) CCMAIL: kde-imaging@kde.org BUG : 107905 CCBUGS: 128394 M +0 -1 Makefile.am M +7 -0 configure.in.bot M +17 -0 configure.in.in M +6 -1 kipiplugins.kdevelop M +4 -2 rawconverter/Makefile.am M +201 -1 rawconverter/dcrawiface.cpp M +15 -0 rawconverter/dcrawiface.h A rawconverter/exiv2iface.cpp [License: GPL] A rawconverter/exiv2iface.h [License: GPL] --- trunk/extragear/libs/kipi-plugins/Makefile.am #584762:584763 @@ -25,7 +25,6 @@ TIMEADJUSTDIR = $(timeadjustdir) endif - if compile_ACQUIREIMAGES ACQUIREIMAGESDIR = acquireimages endif --- trunk/extragear/libs/kipi-plugins/configure.in.bot #584762:584763 @@ -58,3 +58,10 @@ echo "" all_tests=bad fi + +if test "x$have_exiv2" != "xyes"; then + echo "" + echo "You're missing Exiv2 library. The rawconverter plugin will not be compiled." + echo "" + all_tests=bad +fi --- trunk/extragear/libs/kipi-plugins/configure.in.in #584762:584763 @@ -168,6 +168,23 @@ AM_CONDITIONAL(compile_HTMLEXPORT, test -n "${XSLT_CONFIG}") +#------------------------------------------------------------------ +# Check for Exiv2 library +#------------------------------------------------------------------ + +have_exiv2='no' +AC_PATH_PROG(EXIV2_CONFIG,exiv2-config) +KDE_CHECK_HEADER(exiv2/exif.hpp, have_exiv2=yes, have_exiv2=no) + +if test "x$have_exiv2" != "xyes"; then + AC_WARN([Exiv2 library is require for the rawconvert plugin.]) +else + LIB_EXIV2="-lexiv2" + AC_SUBST(LIB_EXIV2) +fi + +AM_CONDITIONAL(compile_RAWCONVERTER, test -n "${EXIV2_CONFIG}") + # ---------------------------------------------------------- # # Slideshow plugin tests --- trunk/extragear/libs/kipi-plugins/kipiplugins.kdevelop #584762:584763 @@ -110,7 +110,7 @@ <run> <directoryradio>custom</directoryradio> <customdirectory>/</customdirectory> - <mainprogram>/usr/bin/digikam</mainprogram> + <mainprogram>/opt/kde3/bin/digikam</mainprogram> <programargs/> <terminal>false</terminal> <autocompile>false</autocompile> @@ -167,6 +167,11 @@ <inlineGet>true</inlineGet> <inlineSet>true</inlineSet> </creategettersetter> + <qt> + <used>false</used> + <version>3</version> + <root>/usr/lib/qt3</root> + </qt> </kdevcppsupport> <kdevcvsservice> <recursivewhenupdate>true</recursivewhenupdate> --- trunk/extragear/libs/kipi-plugins/rawconverter/Makefile.am #584762:584763 @@ -1,5 +1,6 @@ METASOURCES = AUTO SUBDIRS = profiles +KDE_CXXFLAGS = $(USE_EXCEPTIONS) INCLUDES = -I$(top_srcdir)/kipi-plugins/common/include \ $(LIBKIPI_CFLAGS) $(all_includes) @@ -12,10 +13,11 @@ # Srcs for the plugin kipiplugin_rawconverter_la_SOURCES = plugin_rawconverter.cpp dcrawiface.cpp savesettingswidget.cpp \ batchdialog.cpp actionthread.cpp dcrawsettingswidget.cpp \ - singledialog.cpp previewwidget.cpp iccjpeg.c dcrawbinary.cpp + singledialog.cpp previewwidget.cpp iccjpeg.c dcrawbinary.cpp \ + exiv2iface.cpp # Libs needed by the plugin -kipiplugin_rawconverter_la_LIBADD = -ljpeg -lpng $(LIB_TIFF) $(LIBKIPI_LIBS) $(LIB_KIO) $(LIB_KDEUI) $(LIB_KDECORE) $(LIB_QT) +kipiplugin_rawconverter_la_LIBADD = -ljpeg -lpng $(LIB_TIFF) $(LIBKIPI_LIBS) $(LIB_KIO) $(LIB_EXIV2) $(LIB_KDEUI) $(LIB_KDECORE) $(LIB_QT) # LD flags for the plugin kipiplugin_rawconverter_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries) --- trunk/extragear/libs/kipi-plugins/rawconverter/dcrawiface.cpp #584762:584763 @@ -38,7 +38,6 @@ #include <jpeglib.h> #include <tiffio.h> #include <tiffvers.h> -#include <png.h> #include "iccjpeg.h" } @@ -63,6 +62,7 @@ #include "pluginsversion.h" #include "rawfiles.h" +#include "exiv2iface.h" #include "dcrawbinary.h" #include "dcrawiface.h" #include "dcrawiface.moc" @@ -468,6 +468,12 @@ jpeg_finish_compress(&cinfo); fclose(f); + + // Metadata restoration. + Exiv2Iface exiv2Ifave; + exiv2Ifave.load(filePath); + exiv2Ifave.setImageProgramId(QString("Kipi Raw Converter"), QString(kipiplugins_version)); + exiv2Ifave.save(destPath); break; } case RawDecodingSettings::PNG: @@ -515,6 +521,23 @@ text.compression = PNG_TEXT_COMPRESSION_zTXt; png_set_text(png_ptr, info_ptr, &(text), 1); + // Metadata restoration. + Exiv2Iface exiv2Ifave; + exiv2Ifave.load(filePath); + exiv2Ifave.setImageProgramId(QString("Kipi Raw Converter"), QString(kipiplugins_version)); + + // Store Exif data. + QByteArray ba = exiv2Ifave.getExif(); + const uchar ExifHeader[] = {0x45, 0x78, 0x69, 0x66, 0x00, 0x00}; + QByteArray profile = QByteArray(ba.size() + sizeof(ExifHeader)); + memcpy(profile.data(), ExifHeader, sizeof(ExifHeader)); + memcpy(profile.data()+sizeof(ExifHeader), ba.data(), ba.size()); + writeRawProfile(png_ptr, info_ptr, "exif", profile.data(), (png_uint_32) profile.size()); + + // Store Iptc data. + QByteArray ba2 = exiv2Ifave.getIptc(); + writeRawProfile(png_ptr, info_ptr, "iptc", ba2.data(), (png_uint_32) ba2.size()); + png_write_info(png_ptr, info_ptr); png_set_shift(png_ptr, &sig_bit); png_set_packing(png_ptr); @@ -570,6 +593,21 @@ w = TIFFScanlineSize(tif); TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, TIFFDefaultStripSize(tif, 0)); + + // Metadata restoration. + Exiv2Iface exiv2Ifave; + exiv2Ifave.load(filePath); + exiv2Ifave.setImageProgramId(QString("Kipi Raw Converter"), QString(kipiplugins_version)); + + // Store Exif data. + // TODO + + // Store Iptc data. + QByteArray ba2 = exiv2Ifave.getIptc(true); +#if defined(TIFFTAG_PHOTOSHOP) + TIFFSetField (tif, TIFFTAG_PHOTOSHOP, (uint32)ba2.size(), (uchar *)ba2.data()); +#endif + QString libtiffver(TIFFLIB_VERSION_STR); libtiffver.replace('\n', ' '); soft.append(QString(" ( %1 )").arg(libtiffver)); @@ -841,4 +879,166 @@ kdDebug() << "Dcraw StdErr: " << message << endl; } +void DcrawIface::writeRawProfile(png_struct *ping, png_info *ping_info, char *profile_type, + char *profile_data, png_uint_32 length) +{ + png_textp text; + + register long i; + + uchar *sp; + + png_charp dp; + + png_uint_32 allocated_length, description_length; + + const uchar hex[16] = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'}; + + kdDebug() << "Writing Raw profile: type=" << profile_type << ", length=" << length << endl; + + text = (png_textp) png_malloc(ping, (png_uint_32) sizeof(png_text)); + description_length = strlen((const char *) profile_type); + allocated_length = (png_uint_32) (length*2 + (length >> 5) + 20 + description_length); + + text[0].text = (png_charp) png_malloc(ping, allocated_length); + text[0].key = (png_charp) png_malloc(ping, (png_uint_32) 80); + text[0].key[0] = '\0'; + + concatenateString(text[0].key, "Raw profile type ", 4096); + concatenateString(text[0].key, (const char *) profile_type, 62); + + sp = (uchar*)profile_data; + dp = text[0].text; + *dp++='\n'; + + copyString(dp, (const char *) profile_type, allocated_length); + + dp += description_length; + *dp++='\n'; + + formatString(dp, allocated_length-strlen(text[0].text), "%8lu ", length); + + dp += 8; + + for (i=0; i < (long) length; i++) + { + if (i%36 == 0) + *dp++='\n'; + + *(dp++)=(char) hex[((*sp >> 4) & 0x0f)]; + *(dp++)=(char) hex[((*sp++ ) & 0x0f)]; + } + + *dp++='\n'; + *dp='\0'; + text[0].text_length = (png_size_t) (dp-text[0].text); + text[0].compression = -1; + + if (text[0].text_length <= allocated_length) + png_set_text(ping, ping_info,text, 1); + + png_free(ping, text[0].text); + png_free(ping, text[0].key); + png_free(ping, text); +} + +size_t DcrawIface::concatenateString(char *destination, const char *source, const size_t length) +{ + register char *q; + + register const char *p; + + register size_t i; + + size_t count; + + if ( !destination || !source || length == 0 ) + return 0; + + p = source; + q = destination; + i = length; + + while ((i-- != 0) && (*q != '\0')) + q++; + + count = (size_t) (q-destination); + i = length-count; + + if (i == 0) + return(count+strlen(p)); + + while (*p != '\0') + { + if (i != 1) + { + *q++=(*p); + i--; + } + p++; + } + + *q='\0'; + + return(count+(p-source)); +} + +size_t DcrawIface::copyString(char *destination, const char *source, const size_t length) +{ + register char *q; + + register const char *p; + + register size_t i; + + if ( !destination || !source || length == 0 ) + return 0; + + p = source; + q = destination; + i = length; + + if ((i != 0) && (--i != 0)) + { + do + { + if ((*q++=(*p++)) == '\0') + break; + } + while (--i != 0); + } + + if (i == 0) + { + if (length != 0) + *q='\0'; + + while (*p++ != '\0'); + } + + return((size_t) (p-source-1)); +} + +long DcrawIface::formatString(char *string, const size_t length, const char *format,...) +{ + long n; + + va_list operands; + + va_start(operands,format); + n = (long) formatStringList(string, length, format, operands); + va_end(operands); + return(n); +} + +long DcrawIface::formatStringList(char *string, const size_t length, const char *format, va_list operands) +{ + int n = vsnprintf(string, length, format, operands); + + if (n < 0) + string[length-1] = '\0'; + + return((long) n); +} + } // namespace KIPIRawConverterPlugin --- trunk/extragear/libs/kipi-plugins/rawconverter/dcrawiface.h #584762:584763 @@ -22,6 +22,13 @@ #ifndef DCRAWIFACE_H #define DCRAWIFACE_H +// C Ansi includes. + +extern "C" +{ +#include <png.h> +} + // Qt Includes. #include <qstring.h> @@ -87,6 +94,14 @@ virtual void customEvent(QCustomEvent *); + void writeRawProfile(png_struct *ping, png_info *ping_info, char *profile_type, + char *profile_data, png_uint_32 length); + + size_t concatenateString(char *destination, const char *source, const size_t length); + size_t copyString(char *destination, const char *source, const size_t length); + long formatString(char *string, const size_t length, const char *format,...); + long formatStringList(char *string, const size_t length, const char *format, va_list operands); + private slots: void slotProcessExited(KProcess *);
*** Bug 137281 has been marked as a duplicate of this bug. ***