Commit 86a40546 authored by Gilles Caulier's avatar Gilles Caulier 🗼
Browse files

Add ImageMagick codecs support as QImage fail-back image loader to be able

to render thumbnails and load image in editor with extra image format as HEIC, FITS, JPEG-XR, XCF.
For the moment, this will support image loading in this formats. Later we can plan to add writting
support if ImageMagick codecs can do it.
BUGS: 385726
BUGS: 360806
BUGS: 393408
FIXED-IN: 6.1.0
parent b29c9547
......@@ -335,6 +335,7 @@ The full list of mandatory (X) and optional (opt) external dependencies required
| liblqr-1 | opt | >= 0.4.2 | http://liblqr.wikidot.com | For Liquid rescale tool | |
| libgphoto2 | opt | >= 2.5 | http://www.gphoto.org | Digital camera drivers support. Need libusb-1 | |
| libgomp | opt | >= 5.0 | https://gcc.gnu.org/onlinedocs/libgomp | OpenMP support for RawEngine | |
| libmagick++ | opt | >= 6.7.0 | https://www.imagemagick.org | ImageMagick codecs support for DImg image loader | Version >= 7.0 recommended |
| DrMingw | opt | >= 0.8.2 | https://github.com/jrfonseca/drmingw | Mingw crash handler (run-time deps only for windows) | |
\section getsourcecode Get Source Code
......
......@@ -9,6 +9,7 @@ General : Update internal libpgf to last 07193.
General : Add compatiblity with OpenCV version 4.
General : MacOS and AppImage bundles are now published with Qt 5.11.3.
General : Add new optional configuration option to compile with Faces Engine Neural Network.
General : Add optional support to ImageMagick codecs to support extra image formats as XCF, FITS, HEIC, etc.
BQM : Add new advanced settings in resize tool.
BQM : All Batch Queue Manager tools become Bqm plugins.
Editor : All Image Editor tools become Editor plugins and are shared with Showfoto.
......
......@@ -319,6 +319,7 @@ find_package(PkgConfig)
find_package(Jasper) # For JPEG 2000 support.
find_package(Eigen3) # For Refocus tool.
find_package(OpenGL) # For Presentation tool.
find_package(ImageMagick COMPONENTS Magick++) # For QImage loader fail back to ImageMagick codecs.
# For Monitor Profiles management with LCMS
find_package(X11)
......@@ -533,6 +534,7 @@ MACRO_BOOL_TO_01(ENABLE_APPSTYLES HAVE_APPSTYLE_SUPPORT)
MACRO_BOOL_TO_01(ENABLE_QWEBENGINE HAVE_QWEBENGINE)
MACRO_BOOL_TO_01(ENABLE_FACESENGINE_DNN HAVE_FACESENGINE_DNN)
MACRO_BOOL_TO_01(ENABLE_DRMINGW HAVE_DRMINGW)
MACRO_BOOL_TO_01(ImageMagick_FOUND HAVE_IMAGE_MAGICK)
# Whether to use Qt's scaling to downscale previews. Under MacOSX, Qt
# can make use of the higher physical resolution of Retina
......@@ -581,6 +583,7 @@ PRINT_OPTIONAL_LIBRARY_STATUS("bison" "https://www.gnu.org/software/
PRINT_OPTIONAL_LIBRARY_STATUS("doxygen" "http://www.doxygen.org" "(version >= 1.8.0)" "digiKam will be compiled without API documentation building support." Doxygen_FOUND)
PRINT_OPTIONAL_LIBRARY_STATUS("flex" "http://flex.sourceforge.net/" "(version >= 2.5.0)" "digiKam will be compiled without Panorama support." FLEX_FOUND)
PRINT_OPTIONAL_LIBRARY_STATUS("libakonadicontact" "https://cgit.kde.org/akonadi-contacts.git/about/" "(version >= ${AKONADI_MIN_VERSION})" "digiKam will be compiled without KDE desktop address book support." KF5AkonadiContact_FOUND)
PRINT_OPTIONAL_LIBRARY_STATUS("libmagick++" "https://www.imagemagick.org" "(version >= 6.7.0)" "digiKam will be compiled without ImageMagick codecs." ImageMagick_FOUND)
PRINT_OPTIONAL_LIBRARY_STATUS("libeigen3" "http://eigen.tuxfamily.org" "(version >= 3.0.0)" "digiKam will be compiled without Refocus tool support." Eigen3_FOUND)
PRINT_OPTIONAL_LIBRARY_STATUS("libgphoto2" "http://www.gphoto.org" "(version >= 2.4.0)" "digiKam will be compiled without GPhoto2 camera drivers support." Gphoto2_FOUND)
PRINT_OPTIONAL_LIBRARY_STATUS("libjasper" "http://www.ece.uvic.ca/~mdadams/jasper" "(version >= 1.7.0)" "digiKam will be compiled without JPEG2000 support." Jasper_FOUND)
......@@ -737,7 +740,11 @@ if(DIGIKAM_CAN_BE_COMPILED)
if(LensFun_FOUND)
include_directories(${LENSFUN_INCLUDE_DIRS})
endif()
if(ImageMagick_FOUND)
include_directories(${ImageMagick_INCLUDE_DIRS})
endif()
# ==========================================================================
# Common targets parts
......
......@@ -169,6 +169,10 @@ if(LensFun_FOUND)
target_link_libraries(digikamcore PUBLIC ${LENSFUN_LIBRARIES})
endif()
if(ImageMagick_FOUND)
target_link_libraries(digikamcore PUBLIC ${ImageMagick_LIBRARIES})
endif()
# for nrfilter
if(OpenCV_FOUND)
target_link_libraries(digikamcore PRIVATE ${OpenCV_LIBRARIES})
......
......@@ -114,6 +114,9 @@
/* Define to 1 if FaceEngine DNN is enabled */
#cmakedefine HAVE_FACESENGINE_DNN 1
/* Define to 1 if ImageMAgick codecs are supported */
#cmakedefine HAVE_IMAGE_MAGICK 1
/* Defines to 1 if the Dr. Mingw crash handler should be used */
#cmakedefine HAVE_DRMINGW 1
......
......@@ -52,6 +52,10 @@
# include "mapwidget.h"
#endif // HAVE_MARBLE
#ifdef HAVE_IMAGE_MAGICK
# include <Magick++.h>
#endif
// C ANSI includes
#ifndef Q_OS_WIN
......@@ -141,6 +145,12 @@ LibsInfoDlg::LibsInfoDlg(QWidget* const parent)
list.insert(i18nc(CONTEXT, "VKontakte support"), SUPPORTED_NO);
#endif // HAVE_VKONTAKTE
#ifdef HAVE_IMAGE_MAGICK
list.insert(i18nc(CONTEXT, "ImageMagick codecs"), QLatin1String(MagickLibVersionText));
#else
list.insert(i18nc(CONTEXT, "ImageMagick codecs support"), SUPPORTED_NO);
#endif // HAVE_IMAGE_MAGICK
QString tiffver = QLatin1String(TIFFLIB_VERSION_STR);
tiffver = tiffver.left(tiffver.indexOf(QLatin1Char('\n')));
tiffver = tiffver.section(QLatin1Char(' '), 2, 2);
......
......@@ -11,7 +11,8 @@ PPM Done TODO N.A N.A N.A yes yes none
PGF Done DONE TODO DONE N.A yes yes libpgf
JPEG2K Done Done Done Done N.A yes yes libjasper
Others file formats are supported only in 8 bits/color/pixel using QImageFormats plugins.
Others file formats are supported only in 8 bits/color/pixel using QImageFormats plugins,
or with fail-back to ImageMAgick codecs (optional).
Supported formats are listed below :
Format Read Write Remarks
......
......@@ -24,6 +24,13 @@
#include "qimageloader.h"
#ifdef HAVE_IMAGE_MAGICK
# define MAGICKCORE_HDRI_ENABLE 0
# define MAGICKCORE_QUANTUM_DEPTH 8
# include <Magick++.h>
using namespace Magick;
#endif
// Qt includes
#include <QImage>
......@@ -66,8 +73,12 @@ bool QImageLoader::load(const QString& filePath, DImgLoaderObserver* const obser
{
qCWarning(DIGIKAM_DIMG_LOG_QIMAGE) << "Can not load \"" << filePath << "\" using DImg::QImageLoader!";
qCWarning(DIGIKAM_DIMG_LOG_QIMAGE) << "Error message from loader:" << reader.errorString();
loadingFailed();
return false;
if (!loadWithImageMagick(filePath, image))
{
loadingFailed();
return false;
}
}
int colorModel = DImg::COLORMODELUNKNOWN;
......@@ -204,4 +215,49 @@ bool QImageLoader::isReadOnly() const
return false;
}
// -- ImageMagick codecs to QImage --------------------------------------------------------
bool QImageLoader::loadWithImageMagick(const QString& path, QImage& qimg)
{
#ifdef HAVE_IMAGE_MAGICK
qCDebug(DIGIKAM_DIMG_LOG_QIMAGE) << "Try to load image with ImageMagick codecs";
try
{
Image image;
image.read(path.toUtf8().constData());
qCDebug(DIGIKAM_DIMG_LOG_QIMAGE) << "IM toQImage:" << image.columns() << image.rows();
qCDebug(DIGIKAM_DIMG_LOG_QIMAGE) << "IM QuantumRange:" << QuantumRange;
Blob* const pixelBlob = new Blob;
image.write(pixelBlob, "BGRA", 8);
qCDebug(DIGIKAM_DIMG_LOG_QIMAGE) << "IM blob size: " << pixelBlob->length();
qimg = QImage((uchar*)pixelBlob->data(), image.columns(), image.rows(), QImage::Format_ARGB32);
qCDebug(DIGIKAM_DIMG_LOG_QIMAGE) << "QImage data size:" << qimg.byteCount();
if (qimg.isNull())
return false;
}
catch (Exception &error_)
{
qCWarning(DIGIKAM_DIMG_LOG_QIMAGE) << "ImageMagick exception [" << path << "]" << error_.what();
qimg = QImage();
return false;
}
return true;
#else
Q_UNUSED(path);
Q_UNUSED(qimg);
return false;
#endif
}
} // namespace Digikam
......@@ -29,6 +29,7 @@
#include "dimgloader.h"
#include "digikam_export.h"
#include "digikam_config.h"
namespace Digikam
{
......@@ -47,6 +48,10 @@ public:
virtual bool sixteenBit() const;
virtual bool isReadOnly() const;
private:
bool loadWithImageMagick(const QString& path, QImage& qimg);
private:
bool m_hasAlpha;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment