[Kde-imaging] [Bug 107905] copy exif data from raw to converted images
Gilles Caulier
caulier.gilles at free.fr
Wed Sep 13 21:35:06 CEST 2006
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
http://bugs.kde.org/show_bug.cgi?id=107905
------- Additional Comments From caulier.gilles free fr 2006-09-13 21:35 -------
SVN commit 583913 by cgilles:
kipi-plugins from trunk : Raw Converter :
- Store icc color space profile used to decode RAW data into target image (JPEG, PNG, TIFF)
- 4 icc color profile files (comming from krita repository) are available : SRGB, ADOBERGB, WIDEGAMUT, PROPHOTO
Actually, the implementation only use SRGB color space
CCBUGS: 107905
M +3 -2 Makefile.am
M +78 -2 dcrawutils.cpp
M +20 -4 dcrawutils.h
A profiles (directory)
A profiles/Makefile.am
AM profiles/adobergb.icm
AM profiles/prophoto.icm
AM profiles/srgb.icm
AM profiles/widegamut.icm
--- trunk/extragear/libs/kipi-plugins/rawconverter/Makefile.am #583912:583913
@ -1,14 +1,15 @
INCLUDES = -I$(top_srcdir)/kipi-plugins/common/include \
$(LIBKIPI_CFLAGS) $(all_includes)
METASOURCES = AUTO
+SUBDIRS = profiles
# Install this plugin in the KDE modules directory
kde_module_LTLIBRARIES = kipiplugin_rawconverter.la
kipiplugin_rawconverter_la_DEPENDENCIES = $(LIBKIPI_LIBS_DEP)
# Srcs for the plugin
kipiplugin_rawconverter_la_SOURCES = plugin_rawconverter.cpp dcrawutils.cpp savesettingswidget.cpp \
- batchdialog.cpp actionthread.cpp dcrawsettingswidget.cpp \
- singledialog.cpp previewwidget.cpp
+ batchdialog.cpp actionthread.cpp dcrawsettingswidget.cpp \
+ singledialog.cpp previewwidget.cpp iccjpeg.c
# 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/dcrawutils.cpp #583912:583913
@ -38,6 +38,7 @
#include <tiffio.h>
#include <tiffvers.h>
#include <png.h>
+#include "iccjpeg.h"
}
// Qt Includes.
@ -50,6 +51,7 @
#include <kdebug.h>
#include <klocale.h>
#include <kprocess.h>
+#include <kstandarddirs.h>
// KIPI include files
@ -355,6 +357,7 @
pclose( f );
+ QByteArray ICCColorProfile = getICCProfilFromFile(rawDecodingSettings.outputColorSpace);
QString soft = QString("Kipi Raw Converter v.%1").arg(kipi_version);
QFileInfo fi(filePath);
destPath = fi.dirPath(true) + QString("/") + ".kipi-rawconverter-tmp-"
@ -380,7 +383,8 @
int row_stride;
JSAMPROW row_pointer[1];
-
+
+ // Init JPEG compressor.
cinfo.err = jpeg_std_error(&jerr);
jpeg_create_compress(&cinfo);
jpeg_stdio_dest(&cinfo, f);
@ -395,8 +399,13 @
cinfo.comp_info[0].v_samp_factor = 1;
jpeg_set_quality(&cinfo, 100, true);
jpeg_start_compress(&cinfo, true);
+
+ // Write ICC color profil.
+ if (!ICCColorProfile.isEmpty())
+ write_icc_profile (&cinfo, (JOCTET *)ICCColorProfile.data(), ICCColorProfile.size());
+
+ // Write image data
row_stride = cinfo.image_width * 3;
-
while (cinfo.next_scanline < cinfo.image_height)
{
row_pointer[0] = imgData + (cinfo.next_scanline * row_stride);
@ -435,6 +444,14 @
png_set_sBIT(png_ptr, info_ptr, &sig_bit);
png_set_compression_level(png_ptr, 9);
+ // Write ICC profil.
+ if (!ICCColorProfile.isEmpty())
+ {
+ png_set_iCCP(png_ptr, info_ptr, "icc", PNG_COMPRESSION_TYPE_BASE,
+ ICCColorProfile.data(), ICCColorProfile.size());
+ }
+
+
QString libpngver(PNG_HEADER_VERSION_STRING);
libpngver.replace('\n', ' ');
soft.append(QString(" (%1)").arg(libpngver));
@ -503,6 +520,16 @
soft.append(QString(" ( %1 )").arg(libtiffver));
TIFFSetField(tif, TIFFTAG_SOFTWARE, (const char*)soft.ascii());
+ // Write ICC profil.
+ if (!ICCColorProfile.isEmpty())
+ {
+#if defined(TIFFTAG_ICCPROFILE)
+ TIFFSetField(tif, TIFFTAG_ICCPROFILE, (uint32)ICCColorProfile.size(),
+ (uchar *)ICCColorProfile.data());
+#endif
+ }
+
+ // Write image data
for (y = 0; y < height; y++)
{
data = imgData + (y * width * 3);
@ -541,4 +568,53 @
return true;
}
+QByteArray DcrawUtils::getICCProfilFromFile(RawDecodingSettings::OutputColorSpace colorSpace)
+{
+ QString filePath;
+ KGlobal::dirs()->addResourceType("profiles", KGlobal::dirs()->kde_default("data") + "kipiplugin_rawconverter/profiles");
+
+ switch(colorSpace)
+ {
+ case RawDecodingSettings::SRGB:
+ {
+ filePath = KGlobal::dirs()->findResourceDir("profiles", "srgb.icm");
+ filePath.append("srgb.icm");
+ break;
+ }
+ case RawDecodingSettings::ADOBERGB:
+ {
+ filePath = KGlobal::dirs()->findResourceDir("profiles", "adobergb.icm");
+ filePath.append("adobergb.icm");
+ break;
+ }
+ case RawDecodingSettings::WIDEGAMMUT:
+ {
+ filePath = KGlobal::dirs()->findResourceDir("profiles", "widegamut.icm");
+ filePath.append("widegamut.icm");
+ break;
+ }
+ case RawDecodingSettings::PROPHOTO:
+ {
+ filePath = KGlobal::dirs()->findResourceDir("profiles", "prophoto.icm");
+ filePath.append("prophoto.icm");
+ break;
+ }
+ default:
+ break;
+ }
+
+ if ( filePath.isEmpty() )
+ return QByteArray();
+
+ QFile file(filePath);
+ if ( !file.open(IO_ReadOnly) )
+ return QByteArray();
+
+ QByteArray data(file.size());
+ QDataStream stream( &file );
+ stream.readRawBytes(data.data(), data.size());
+ file.close();
+ return data;
+}
+
} // namespace KIPIRawConverterPlugin
--- trunk/extragear/libs/kipi-plugins/rawconverter/dcrawutils.h #583912:583913
@ -23,6 +23,7 @
// Qt Includes.
+#include <qcstring.h>
#include <qstring.h>
#include <qimage.h>
@ -49,6 +50,15 @
PNG
};
+ enum OutputColorSpace
+ {
+ RAWCOLOR = 0,
+ SRGB,
+ ADOBERGB,
+ WIDEGAMMUT,
+ PROPHOTO
+ };
+
RawDecodingSettings()
{
enableNoiseReduction = false;
@ -59,6 +69,7 @
RAWQuality = BILINEAR;
outputFileFormat = PNG;
+ outputColorSpace = SRGB;
RGBInterpolate4Colors = false;
SuperCCDsecondarySensor = false;
@ -94,10 +105,10 @
0 = Clip all highlights to solid white.
1 = Leave highlights unclipped in various shades of pink.
2-9 = Reconstruct highlights. Low numbers favor whites; high numbers favor colors.*/
- int unclipColors;
+ int unclipColors;
- /** RAW quality decoding factor value. */
- int RAWQuality;
+ /** RAW quality decoding factor value. See DecodingQuality values for details. */
+ DecodingQuality RAWQuality;
/** RAW file decoding using bilateral filter to reduce noise. This is '-B sigma_domain sigma_range'
dcraw option to smooth noise while preserving edges. sigma_domain is in units of pixels, while
@ -114,7 +125,10 @
float brightness;
/** The file format used to convert RAW data. See OutputFormat values for details. */
- int outputFileFormat;
+ OutputFormat outputFileFormat;
+
+ /** The output color space used to decoded RAW data. See OutputColorSpace values for details. */
+ OutputColorSpace outputColorSpace;
};
class DcrawUtils
@ -140,6 +154,8 @
static bool decodeRAWImage(const QString& filePath, QString& destPath,
RawDecodingSettings rawDecodingSettings);
+ static QByteArray getICCProfilFromFile(RawDecodingSettings::OutputColorSpace colorSpace);
+
};
} // namespace KIPIRawConverterPlugin
** trunk/extragear/libs/kipi-plugins/rawconverter/profiles/adobergb.icm #property svn:mime-type
+ application/octet-stream
** trunk/extragear/libs/kipi-plugins/rawconverter/profiles/prophoto.icm #property svn:mime-type
+ application/octet-stream
** trunk/extragear/libs/kipi-plugins/rawconverter/profiles/srgb.icm #property svn:mime-type
+ application/octet-stream
** trunk/extragear/libs/kipi-plugins/rawconverter/profiles/widegamut.icm #property svn:mime-type
+ application/octet-stream
More information about the Kde-imaging
mailing list