[Digikam-devel] [Bug 126326] digikam: camera download: auto-rotated images loose EXIF info when 'No EXIF information found.' is written to console
Gilles Caulier
caulier.gilles at free.fr
Wed May 10 20:23:22 BST 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=126326
------- Additional Comments From caulier.gilles free fr 2006-05-10 21:23 -------
SVN commit 539482 by cgilles:
JpegLossLess plugin : backport fix from digiKam (see file 126326 in B.K.O) about an incompatibility with JPEG implementation and "enable-final" option!
CCMAIL: kde-imaging kde org
CCBUGS: 126326
M +6 -2 Makefile.am
M +4 -4 convert2grayscale.cpp
M +4 -4 imageflip.cpp
M +62 -44 imagerotate.cpp
--- trunk/extragear/libs/kipi-plugins/jpeglossless/Makefile.am #539481:539482
@ -1,7 +1,11 @
METASOURCES = AUTO
-KDE_CXXFLAGS = $(USE_EXCEPTIONS)
INCLUDES = $(LIBKIPI_CFLAGS) $(LIBKEXIF_CFLAGS) $(all_includes)
+# --enable-final triggers: http://bugs.kde.org/show_bug.cgi?id=126326
+# digikam: camera download: auto-rotated images loose EXIF info ...
+# So make sure nofinal is always used here!
+KDE_OPTIONS = nofinal
+
# Install this plugin in the KDE modules directory
kde_module_LTLIBRARIES = kipiplugin_jpeglossless.la
@ -12,7 +16,7 @
imagerotate.cpp convert2grayscale.cpp imageflip.cpp
kipiplugin_jpeglossless_la_LIBADD = $(LIB_KPARTS) \
- -ljpeg -lMagick++ $(LIBKIPI_LIBS) $(LIBKEXIF_LIBS)
+ -ljpeg -lWand $(LIBKIPI_LIBS) $(LIBKEXIF_LIBS)
kipiplugin_jpeglossless_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries)
--- trunk/extragear/libs/kipi-plugins/jpeglossless/convert2grayscale.cpp #539481:539482
@ -41,9 +41,9 @
#include <kdebug.h>
#include <kurl.h>
-// ImageMgick includes.
+// ImageMagick includes.
-#include <Magick++.h>
+//#include <Magick++.h>
// Local includes.
@ -192,7 +192,7 @
bool image2GrayScaleImageMagick(const QString& src, const QString& dest, QString& err)
{
- try
+/* try
{
Magick::Image image;
std::string srcFileName(QFile::encodeName(src));
@ -209,7 +209,7 @
err = i18n("Cannot convert to gray scale: %1").arg(error_.what());
kdError() << "Convert2GrayScale: ImageMagick exception: " << error_.what() << endl;
return false;
- }
+ }*/
}
} // NameSpace KIPIJPEGLossLessPlugin
--- trunk/extragear/libs/kipi-plugins/jpeglossless/imageflip.cpp #539481:539482
@ -44,9 +44,9 @
#include <libkexif/kexifdata.h>
-// ImageMgick includes.
+// ImageMagick includes.
-#include <Magick++.h>
+//#include <Magick++.h>
// Local includes
@ -131,7 +131,7 @
bool flipImageMagick(const QString& src, const QString& dest, FlipAction action, QString& err)
{
- try
+/* try
{
Magick::Image image;
std::string srcFileName(QFile::encodeName(src));
@ -166,7 +166,7 @
err = i18n("Cannot flip: %1").arg(error_.what());
kdError() << "ImageFlip: ImageMagick exception: " << error_.what() << endl;
return false;
- }
+ }*/
}
} // NameSpace KIPIJPEGLossLessPlugin
--- trunk/extragear/libs/kipi-plugins/jpeglossless/imagerotate.cpp #539481:539482
@ -26,8 +26,6 @
#include <cstdio>
#include <cstdlib>
-#include <cassert>
-#include <string>
// Qt includes.
@ -47,10 +45,6 @
#include <libkexif/kexifdata.h>
-// ImageMgick includes.
-
-#include <Magick++.h>
-
// Local includes.
#include "imagerotate.h"
@ -63,6 +57,7 @
#include <sys/types.h>
#include <unistd.h>
#include <jpeglib.h>
+#include <wand/magick-wand.h>
#include "transupp.h"
#include "jpegtransform.h"
}
@ -145,51 +140,74 @
bool rotateImageMagick(const QString& src, const QString& dest, RotateAction angle, QString& err)
{
- try
+ bool valRet = true;
+ MagickWandGenesis();
+ PixelWand *background = NewPixelWand();
+ MagickWand *magickWand = NewMagickWand();
+ MagickBooleanType status = MagickReadImage(magickWand, QFile::encodeName(src));
+
+ if (status == MagickFalse)
{
- Magick::Image image;
- std::string srcFileName(QFile::encodeName(src));
- image.read(srcFileName);
+ err = i18n("Failed to load original image");
+ valRet = false;
+ goto Exit_Method;
+ }
- switch(angle)
+ PixelSetColor(background, "#000000");
+
+ switch(angle)
+ {
+ case (Rot90):
+ {
+ status = MagickRotateImage(magickWand, background, 90.0);
+ break;
+ }
+ case (Rot180):
{
- case (Rot90):
- {
- image.rotate(90.0);
- break;
- }
- case (Rot180):
- {
- image.rotate(180.0);
- break;
- }
- case (Rot270):
- {
- image.rotate(270.0);
- break;
- }
- case (Rot0):
- {
- break;
- }
- default:
- {
- kdError() << "ImageRotate: Nonstandard rotation angle" << endl;
- err = i18n("Nonstandard rotation angle");
- return false;
- }
+ status = MagickRotateImage(magickWand, background, 180.0);
+ break;
}
-
- std::string destFileName(QFile::encodeName(dest));
- image.write(destFileName);
- return true;
+ case (Rot270):
+ {
+ status = MagickRotateImage(magickWand, background, 270.0);
+ break;
+ }
+ case (Rot0):
+ {
+ break;
+ }
+ default:
+ {
+ kdError() << "ImageRotate: Nonstandard rotation angle" << endl;
+ err = i18n("Nonstandard rotation angle");
+ valRet = false;
+ goto Exit_Method;
+ }
}
- catch( std::exception &error_ )
+
+ if (status == MagickFalse)
{
- err = i18n("Cannot rotating: %1").arg(error_.what());
- kdError() << "ImageRotate: ImageMagick exception: " << error_.what() << endl;
- return false;
+ err = i18n("Failed to process image rotation image");
+ valRet = false;
+ goto Exit_Method;
}
+
+ status = MagickWriteImages(magickWand, QFile::encodeName(dest), MagickTrue);
+
+ if (status == MagickFalse)
+ {
+ err = i18n("Failed to save target image");
+ valRet = false;
+ goto Exit_Method;
+ }
+
+Exit_Method:
+
+ if (background) DestroyPixelWand(background);
+ MagickClearException(magickWand);
+ if (magickWand) DestroyMagickWand(magickWand);
+ MagickWandTerminus();
+ return valRet;
}
} // NameSpace KIPIJPEGLossLessPlugin
More information about the Digikam-devel
mailing list