Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 42774d6e authored by Maik Qualmann's avatar Maik Qualmann

Merge branch 'master' of invent.kde.org:graphics/digikam

parents 4bc95c36 095bf185
Pipeline #26001 passed with stage
in 56 minutes and 51 seconds
......@@ -47,7 +47,8 @@ set(libdmetadata_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/dmetadata/dmetadata.cpp
${CMAKE_CURRENT_SOURCE_DIR}/dmetadata/dmetadata_video.cpp
${CMAKE_CURRENT_SOURCE_DIR}/dmetadata/dmetadata_heif.cpp
${CMAKE_CURRENT_SOURCE_DIR}/dmetadata/dmetadata_libheif.cpp
${CMAKE_CURRENT_SOURCE_DIR}/dmetadata/dmetadata_libraw.cpp
${CMAKE_CURRENT_SOURCE_DIR}/dmetadata/dmetadata_fileio.cpp
${CMAKE_CURRENT_SOURCE_DIR}/dmetadata/dmetadata_comments.cpp
${CMAKE_CURRENT_SOURCE_DIR}/dmetadata/dmetadata_template.cpp
......
......@@ -38,8 +38,6 @@
#include "filereadwritelock.h"
#include "metaenginesettings.h"
#include "drawinfo.h"
#include "drawdecoder.h"
#include "digikam_version.h"
#include "digikam_globals.h"
#include "digikam_debug.h"
......@@ -94,71 +92,4 @@ bool DMetadata::applyChanges(bool setVersion) const
return MetaEngine::applyChanges(setVersion);
}
bool DMetadata::loadUsingRawEngine(const QString& filePath)
{
DRawInfo identify;
if (DRawDecoder::rawFileIdentify(identify, filePath))
{
long int num = 1;
long int den = 1;
if (!identify.model.isNull())
{
setExifTagString("Exif.Image.Model", identify.model);
}
if (!identify.make.isNull())
{
setExifTagString("Exif.Image.Make", identify.make);
}
if (!identify.owner.isNull())
{
setExifTagString("Exif.Image.Artist", identify.owner);
}
if (identify.sensitivity != -1)
{
setExifTagLong("Exif.Photo.ISOSpeedRatings", lroundf(identify.sensitivity));
}
if (identify.dateTime.isValid())
{
setImageDateTime(identify.dateTime, false);
}
if (identify.exposureTime != -1.0)
{
convertToRationalSmallDenominator(identify.exposureTime, &num, &den);
setExifTagRational("Exif.Photo.ExposureTime", num, den);
}
if (identify.aperture != -1.0)
{
convertToRational(identify.aperture, &num, &den, 8);
setExifTagRational("Exif.Photo.ApertureValue", num, den);
}
if (identify.focalLength != -1.0)
{
convertToRational(identify.focalLength, &num, &den, 8);
setExifTagRational("Exif.Photo.FocalLength", num, den);
}
if (identify.imageSize.isValid())
{
setItemDimensions(identify.imageSize);
}
// A RAW image is always uncalibrated. */
setItemColorWorkSpace(WORKSPACE_UNCALIBRATED);
return true;
}
return false;
}
} // namespace Digikam
......@@ -4,7 +4,7 @@
* https://www.digikam.org
*
* Date : 2019-09-26
* Description : item metadata interface - HEIF helpers.
* Description : item metadata interface - libheif helpers.
*
* Copyright (C) 2020 by Gilles Caulier <caulier dot gilles at gmail dot com>
*
......@@ -34,8 +34,8 @@
// Local includes
#include "digikam_debug.h"
#include "digikam_config.h"
#include "digikam_debug.h"
#include "heif.h"
namespace Digikam
......
/* ============================================================
*
* This file is a part of digiKam project
* https://www.digikam.org
*
* Date : 2006-02-23
* Description : item metadata interface - libraw helpers.
*
* Copyright (C) 2006-2020 by Gilles Caulier <caulier dot gilles at gmail dot com>
* Copyright (C) 2006-2013 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
* Copyright (C) 2011 by Leif Huhn <leif at dkstat dot com>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* ============================================================ */
#include "dmetadata.h"
// Qt includes
#include <QString>
// Local includes
#include "digikam_config.h"
#include "digikam_debug.h"
#include "drawinfo.h"
#include "drawdecoder.h"
namespace Digikam
{
bool DMetadata::loadUsingRawEngine(const QString& filePath)
{
DRawInfo identify;
if (DRawDecoder::rawFileIdentify(identify, filePath))
{
long int num = 1;
long int den = 1;
if (!identify.model.isNull())
{
setExifTagString("Exif.Image.Model", identify.model);
}
if (!identify.make.isNull())
{
setExifTagString("Exif.Image.Make", identify.make);
}
if (!identify.owner.isNull())
{
setExifTagString("Exif.Image.Artist", identify.owner);
}
if (identify.sensitivity != -1)
{
setExifTagLong("Exif.Photo.ISOSpeedRatings", lroundf(identify.sensitivity));
}
if (identify.dateTime.isValid())
{
setImageDateTime(identify.dateTime, false);
}
if (identify.exposureTime != -1.0)
{
convertToRationalSmallDenominator(identify.exposureTime, &num, &den);
setExifTagRational("Exif.Photo.ExposureTime", num, den);
}
if (identify.aperture != -1.0)
{
convertToRational(identify.aperture, &num, &den, 8);
setExifTagRational("Exif.Photo.ApertureValue", num, den);
}
if (identify.focalLength != -1.0)
{
convertToRational(identify.focalLength, &num, &den, 8);
setExifTagRational("Exif.Photo.FocalLength", num, den);
}
if (identify.imageSize.isValid())
{
setItemDimensions(identify.imageSize);
}
// A RAW image is always uncalibrated. */
setItemColorWorkSpace(WORKSPACE_UNCALIBRATED);
return true;
}
return false;
}
} // namespace Digikam
......@@ -114,9 +114,13 @@ bool DRawDecoder::loadEmbeddedPreview(QByteArray& imgData, const QString& path)
LibRaw* const raw = new LibRaw;
#ifdef Q_OS_WIN
int ret = raw->open_file((const wchar_t*)path.utf16());
#else
int ret = raw->open_file(path.toUtf8().constData());
#endif
if (ret != LIBRAW_SUCCESS)
......@@ -169,9 +173,13 @@ bool DRawDecoder::loadHalfPreview(QImage& image, const QString& path)
raw->imgdata.params.half_size = 1; // Half-size color image (3x faster than -q).
#ifdef Q_OS_WIN
int ret = raw->open_file((const wchar_t*)path.utf16());
#else
int ret = raw->open_file(path.toUtf8().constData());
#endif
if (ret != LIBRAW_SUCCESS)
......@@ -211,9 +219,13 @@ bool DRawDecoder::loadHalfPreview(QByteArray& imgData, const QString& path)
LibRaw* const raw = new LibRaw;
#ifdef Q_OS_WIN
int ret = raw->open_file((const wchar_t*)path.utf16());
#else
int ret = raw->open_file(path.toUtf8().constData());
#endif
if (ret != LIBRAW_SUCCESS)
......@@ -348,9 +360,13 @@ bool DRawDecoder::rawFileIdentify(DRawInfo& identify, const QString& path)
LibRaw* const raw = new LibRaw;
#ifdef Q_OS_WIN
int ret = raw->open_file((const wchar_t*)path.utf16());
#else
int ret = raw->open_file(path.toUtf8().constData());
#endif
if (ret != LIBRAW_SUCCESS)
......@@ -411,9 +427,13 @@ bool DRawDecoder::extractRAWData(const QString& filePath,
raw->set_progress_handler(callbackForLibRaw, d);
#ifdef Q_OS_WIN
int ret = raw->open_file((const wchar_t*)filePath.utf16());
#else
int ret = raw->open_file(filePath.toUtf8().constData());
#endif
if (ret != LIBRAW_SUCCESS)
......
......@@ -120,9 +120,9 @@ void DRawDecoder::Private::fillIndentifyInfo(LibRaw* const raw, DRawInfo& identi
identify.exposureTime = raw->imgdata.other.shutter;
identify.aperture = raw->imgdata.other.aperture;
identify.focalLength = raw->imgdata.other.focal_len;
identify.imageSize = QSize(raw->imgdata.sizes.width, raw->imgdata.sizes.height);
identify.fullSize = QSize(raw->imgdata.sizes.raw_width, raw->imgdata.sizes.raw_height);
identify.outputSize = QSize(raw->imgdata.sizes.iwidth, raw->imgdata.sizes.iheight);
identify.imageSize = QSize(raw->imgdata.sizes.width, raw->imgdata.sizes.height);
identify.fullSize = QSize(raw->imgdata.sizes.raw_width, raw->imgdata.sizes.raw_height);
identify.outputSize = QSize(raw->imgdata.sizes.iwidth, raw->imgdata.sizes.iheight);
identify.thumbSize = QSize(raw->imgdata.thumbnail.twidth, raw->imgdata.thumbnail.theight);
identify.topMargin = raw->imgdata.sizes.top_margin;
identify.leftMargin = raw->imgdata.sizes.left_margin;
......@@ -485,9 +485,13 @@ bool DRawDecoder::Private::loadFromLibraw(const QString& filePath, QByteArray& i
qCDebug(DIGIKAM_RAWENGINE_LOG) << m_parent->m_decoderSettings;
#ifdef Q_OS_WIN
int ret = raw->open_file((const wchar_t*)filePath.utf16());
#else
int ret = raw->open_file(filePath.toUtf8().constData());
#endif
if (ret != LIBRAW_SUCCESS)
......
......@@ -47,14 +47,18 @@ QMap<QString, QString> s_rawFileExtensionsdWithDesc()
{
QMap<QString, QString> map;
// NOTE: extension list Version 1 and 2 are taken from http://www.cybercom.net/~dcoffin/dcraw/rawphoto.c
//
// Ext Descriptions From
// www.file-extensions.org
// en.wikipedia.org/wiki/RAW_file_format
// filext.com
// NOTE: VERSION 1
/**
* NOTE: extension list Version 1 and 2 are taken from http://www.cybercom.net/~dcoffin/dcraw/rawphoto.c
*
* Ext Descriptions From
* www.file-extensions.org
* en.wikipedia.org/wiki/RAW_file_format
* filext.com
*/
/**
* NOTE: VERSION 1
*/
map.insert(QLatin1String("bay"), i18n("Casio Digital Camera Raw File Format"));
map.insert(QLatin1String("bmq"), i18n("NuCore Raw Image File"));
......@@ -111,7 +115,9 @@ QMap<QString, QString> s_rawFileExtensionsdWithDesc()
*/
map.insert(QLatin1String("arw"), i18n("Sony Digital Camera Raw Image Format"));
// NOTE: VERSION 2
/**
* NOTE: VERSION 2
*/
map.insert(QLatin1String("3fr"), i18n("Hasselblad Digital Camera Raw Image Format"));
map.insert(QLatin1String("cine"), i18n("Phantom Software Raw Image File"));
......@@ -123,15 +129,21 @@ QMap<QString, QString> s_rawFileExtensionsdWithDesc()
map.insert(QLatin1String("rw2"), i18n("Panasonic LX3 Digital Camera Raw Image Format"));
map.insert(QLatin1String("sti"), i18n("Sinar Capture Shop Raw Image File"));
// NOTE: VERSION 3
/**
* NOTE: VERSION 3
*/
map.insert(QLatin1String("rwl"), i18n("Leica Digital Camera Raw Image Format"));
// NOTE: VERSION 4
/**
* NOTE: VERSION 4
*/
map.insert(QLatin1String("srw"), i18n("Samsung Raw Image Format"));
// NOTE: VERSION 5
/**
* NOTE: VERSION 5
*/
map.insert(QLatin1String("cr3"), i18n("Canon Digital Camera RAW Image Format version 3.0"));
/*
......@@ -150,7 +162,9 @@ QMap<QString, QString> s_rawFileExtensionsdWithDesc()
int s_rawFileExtensionsVersion()
{
// NOTE: increment this number whenever you change the above strings
/**
* NOTE: increment this number whenever you change the above strings
*/
return 5;
}
......
......@@ -34,7 +34,7 @@ DRawInfo::DRawInfo()
exposureTime = -1.0;
aperture = -1.0;
focalLength = -1.0;
pixelAspectRatio = 1.0; // Default value. This can be unavailable (depending of camera model).
pixelAspectRatio = 1.0; ///< Default value. This can be unavailable (depending of camera model).
rawColors = -1;
rawImages = -1;
hasIccProfile = false;
......@@ -64,7 +64,7 @@ DRawInfo::DRawInfo()
{
cameraColorMatrix1[x][y] = 0.0;
cameraColorMatrix2[x][y] = 0.0;
cameraXYZMatrix[y][x] = 0.0; // NOTE: see B.K.O # 253911 : [y][x] not [x][y]
cameraXYZMatrix[y][x] = 0.0; ///< NOTE: see B.K.O # 253911 : [y][x] not [x][y]
}
}
}
......@@ -75,68 +75,68 @@ DRawInfo::~DRawInfo()
bool DRawInfo::isEmpty()
{
if (make.isEmpty() &&
model.isEmpty() &&
filterPattern.isEmpty() &&
colorKeys.isEmpty() &&
DNGVersion.isEmpty() &&
exposureTime == -1.0 &&
aperture == -1.0 &&
focalLength == -1.0 &&
pixelAspectRatio == 1.0 &&
sensitivity == -1.0 &&
rawColors == -1 &&
rawImages == -1 &&
blackPoint == 0 &&
blackPointCh[0] == 0 &&
blackPointCh[1] == 0 &&
blackPointCh[2] == 0 &&
blackPointCh[3] == 0 &&
whitePoint == 0 &&
topMargin == 0 &&
leftMargin == 0 &&
!dateTime.isValid() &&
!imageSize.isValid() &&
!fullSize.isValid() &&
!outputSize.isValid() &&
!thumbSize.isValid() &&
cameraColorMatrix1[0][0] == 0.0 &&
cameraColorMatrix1[0][1] == 0.0 &&
cameraColorMatrix1[0][2] == 0.0 &&
cameraColorMatrix1[0][3] == 0.0 &&
cameraColorMatrix1[1][0] == 0.0 &&
cameraColorMatrix1[1][1] == 0.0 &&
cameraColorMatrix1[1][2] == 0.0 &&
cameraColorMatrix1[1][3] == 0.0 &&
cameraColorMatrix1[2][0] == 0.0 &&
cameraColorMatrix1[2][1] == 0.0 &&
cameraColorMatrix1[2][2] == 0.0 &&
cameraColorMatrix1[2][3] == 0.0 &&
cameraColorMatrix2[0][0] == 0.0 &&
cameraColorMatrix2[0][1] == 0.0 &&
cameraColorMatrix2[0][2] == 0.0 &&
cameraColorMatrix2[0][3] == 0.0 &&
cameraColorMatrix2[1][0] == 0.0 &&
cameraColorMatrix2[1][1] == 0.0 &&
cameraColorMatrix2[1][2] == 0.0 &&
cameraColorMatrix2[1][3] == 0.0 &&
cameraColorMatrix2[2][0] == 0.0 &&
cameraColorMatrix2[2][1] == 0.0 &&
cameraColorMatrix2[2][2] == 0.0 &&
cameraColorMatrix2[2][3] == 0.0 &&
cameraXYZMatrix[0][0] == 0.0 &&
cameraXYZMatrix[0][1] == 0.0 &&
cameraXYZMatrix[0][2] == 0.0 &&
cameraXYZMatrix[1][0] == 0.0 &&
cameraXYZMatrix[1][1] == 0.0 &&
cameraXYZMatrix[1][2] == 0.0 &&
cameraXYZMatrix[2][0] == 0.0 &&
cameraXYZMatrix[2][1] == 0.0 &&
cameraXYZMatrix[2][2] == 0.0 &&
cameraXYZMatrix[3][0] == 0.0 &&
cameraXYZMatrix[3][1] == 0.0 &&
cameraXYZMatrix[3][2] == 0.0 &&
orientation == ORIENTATION_NONE
if (make.isEmpty() &&
model.isEmpty() &&
filterPattern.isEmpty() &&
colorKeys.isEmpty() &&
DNGVersion.isEmpty() &&
(exposureTime == -1.0) &&
(aperture == -1.0) &&
(focalLength == -1.0) &&
(pixelAspectRatio == 1.0) &&
(sensitivity == -1.0) &&
(rawColors == -1) &&
(rawImages == -1) &&
(blackPoint == 0) &&
(blackPointCh[0] == 0) &&
(blackPointCh[1] == 0) &&
(blackPointCh[2] == 0) &&
(blackPointCh[3] == 0) &&
(whitePoint == 0) &&
(topMargin == 0) &&
(leftMargin == 0) &&
!dateTime.isValid() &&
!imageSize.isValid() &&
!fullSize.isValid() &&
!outputSize.isValid() &&
!thumbSize.isValid() &&
(cameraColorMatrix1[0][0] == 0.0) &&
(cameraColorMatrix1[0][1] == 0.0) &&
(cameraColorMatrix1[0][2] == 0.0) &&
(cameraColorMatrix1[0][3] == 0.0) &&
(cameraColorMatrix1[1][0] == 0.0) &&
(cameraColorMatrix1[1][1] == 0.0) &&
(cameraColorMatrix1[1][2] == 0.0) &&
(cameraColorMatrix1[1][3] == 0.0) &&
(cameraColorMatrix1[2][0] == 0.0) &&
(cameraColorMatrix1[2][1] == 0.0) &&
(cameraColorMatrix1[2][2] == 0.0) &&
(cameraColorMatrix1[2][3] == 0.0) &&
(cameraColorMatrix2[0][0] == 0.0) &&
(cameraColorMatrix2[0][1] == 0.0) &&
(cameraColorMatrix2[0][2] == 0.0) &&
(cameraColorMatrix2[0][3] == 0.0) &&
(cameraColorMatrix2[1][0] == 0.0) &&
(cameraColorMatrix2[1][1] == 0.0) &&
(cameraColorMatrix2[1][2] == 0.0) &&
(cameraColorMatrix2[1][3] == 0.0) &&
(cameraColorMatrix2[2][0] == 0.0) &&
(cameraColorMatrix2[2][1] == 0.0) &&
(cameraColorMatrix2[2][2] == 0.0) &&
(cameraColorMatrix2[2][3] == 0.0) &&
(cameraXYZMatrix[0][0] == 0.0) &&
(cameraXYZMatrix[0][1] == 0.0) &&
(cameraXYZMatrix[0][2] == 0.0) &&
(cameraXYZMatrix[1][0] == 0.0) &&
(cameraXYZMatrix[1][1] == 0.0) &&
(cameraXYZMatrix[1][2] == 0.0) &&
(cameraXYZMatrix[2][0] == 0.0) &&
(cameraXYZMatrix[2][1] == 0.0) &&
(cameraXYZMatrix[2][2] == 0.0) &&
(cameraXYZMatrix[3][0] == 0.0) &&
(cameraXYZMatrix[3][1] == 0.0) &&
(cameraXYZMatrix[3][2] == 0.0) &&
(orientation == ORIENTATION_NONE)
)
{
return true;
......
......@@ -43,7 +43,8 @@ class DIGIKAM_EXPORT DRawInfo
public:
/** The RAW image orientation values
/**
* The RAW image orientation values
*/
enum ImageOrientation
{
......@@ -73,84 +74,151 @@ public:
public:
/** True if RAW file include an ICC color profile. */
/**
* True if RAW file include an ICC color profile.
*/
bool hasIccProfile;
/** True is RAW file is decodable by dcraw. */
/**
* True is RAW file is decodable by dcraw.
*/
bool isDecodable;
/** The number of RAW colors. */
/**
* The number of RAW colors.
*/
int rawColors;
/** The number of RAW images. */
/**
* The number of RAW images.
*/
int rawImages;
/** Black level from Raw histogram. */
/**
* Black level from Raw histogram.
*/
unsigned int blackPoint;
/** Channel black levels from Raw histogram. */
/**
* Channel black levels from Raw histogram.
*/
unsigned int blackPointCh[4];
/** White level from Raw histogram. */
/**
* White level from Raw histogram.
*/
unsigned int whitePoint;
/** Top margin of raw image. */
/**
* Top margin of raw image.
*/
unsigned int topMargin;
/** Left margin of raw image. */
/**
* Left margin of raw image.
*/
unsigned int leftMargin;
/** The raw image orientation */
/**
* The raw image orientation
*/
ImageOrientation orientation;
/** The sensitivity in ISO used by camera to take the picture. */
/**
* The sensitivity in ISO used by camera to take the picture.
*/
float sensitivity;
/** ==> 1/exposureTime = exposure time in seconds. */
/**
* 1/exposureTime = exposure time in seconds.
*/
float exposureTime;
/** ==> Aperture value in APEX. */
/**
* Aperture value in APEX.
*/
float aperture;
/** ==> Focal Length value in mm. */
/**
* Focal Length value in mm.
*/
float focalLength;
/** The pixel Aspect Ratio if != 1.0. NOTE: if == 1.0, dcraw do not show this value. */
/**
* The pixel Aspect Ratio if != 1.0. NOTE: if == 1.0, dcraw do not show this value.
*/
float pixelAspectRatio;
/** White color balance settings. */
/**
* White color balance settings.
*/
double daylightMult[3];
/** Camera multipliers used for White Balance adjustments */
/**
* Camera multipliers used for White Balance adjustments
*/
double cameraMult[4];