Commit 57c3b724 authored by Marcel Wiesweg's avatar Marcel Wiesweg
Browse files

Do not exif-rotate face thumbnails twice.

Clean up an unused parameter in ThumbnailCreator.

BUG: 313190
FIXED-IN: 3.2.0
parent be13956a
......@@ -31,5 +31,6 @@ BUGFIXES FROM KDE BUGZILLA (alias B.K.O | http://bugs.kde.org):
020 ==> 318154 - digiKam crashes after a few seconds.
021 ==> 318353 - Implement kind of a read-only mode.
022 ==> 166820 - Wish: Specify a ISO over which to apply noise reduction.
023 ==>
023 ==> 313190 - Thumbnails of faces not rotated correctly according to the configuration settings.
024 ==>
......@@ -300,7 +300,8 @@ QImage ThumbnailCreator::load(const QString& path, const QRect& rect, bool prege
if (d->thumbnailStorage == ThumbnailDatabase)
{
// image is stored, or created, unrotated, and is now rotated for display
if (d->exifRotate)
// detail thumbnails are stored readily rotated
if (d->exifRotate && rect.isNull())
{
image.qimage = exifRotate(image.qimage, image.exifOrientation);
}
......@@ -309,10 +310,8 @@ QImage ThumbnailCreator::load(const QString& path, const QRect& rect, bool prege
return image.qimage;
}
QImage ThumbnailCreator::scaleForStorage(const QImage& qimage, bool isFace) const
QImage ThumbnailCreator::scaleForStorage(const QImage& qimage) const
{
Q_UNUSED(isFace)
if (qimage.width() > d->storageSize() || qimage.height() > d->storageSize())
{
/*
......@@ -365,19 +364,19 @@ void ThumbnailCreator::store(const QString& path, const QImage& i) const
store(path, i, QRect());
}
void ThumbnailCreator::storeDetailThumbnail(const QString& path, const QRect& detailRect, const QImage& i, bool isFace) const
void ThumbnailCreator::storeDetailThumbnail(const QString& path, const QRect& detailRect, const QImage& i) const
{
store(path, i, detailRect, isFace);
store(path, i, detailRect);
}
void ThumbnailCreator::store(const QString& path, const QImage& i, const QRect& rect, bool isFace) const
void ThumbnailCreator::store(const QString& path, const QImage& i, const QRect& rect) const
{
if (i.isNull())
{
return;
}
QImage qimage = scaleForStorage(i, isFace);
QImage qimage = scaleForStorage(i);
ThumbnailInfo info = makeThumbnailInfo(path, rect);
ThumbnailImage image;
image.qimage = qimage;
......@@ -427,7 +426,7 @@ void ThumbnailCreator::deleteThumbnailsFromDisk(const QString& filePath) const
// --------------- Thumbnail generation and image handling -----------------------
ThumbnailImage ThumbnailCreator::createThumbnail(const ThumbnailInfo& info, const QRect& detailRect, bool isFace) const
ThumbnailImage ThumbnailCreator::createThumbnail(const ThumbnailInfo& info, const QRect& detailRect) const
{
const QString path = info.filePath;
......@@ -456,82 +455,84 @@ ThumbnailImage ThumbnailCreator::createThumbnail(const ThumbnailInfo& info, cons
qimage = loadImageDetail(info, metadata, detailRect, &profile);
fromDetail = !qimage.isNull();
}
if (qimage.isNull())
else
{
// Try to extract Exif/IPTC preview first.
qimage = loadImagePreview(metadata);
}
if (qimage.isNull())
{
// Try to extract Exif/IPTC preview first.
qimage = loadImagePreview(metadata);
}
QFileInfo fileInfo(path);
// To speed-up thumb extraction, we now try to load the images by the file extension.
QString ext = fileInfo.suffix().toUpper();
QFileInfo fileInfo(path);
// To speed-up thumb extraction, we now try to load the images by the file extension.
QString ext = fileInfo.suffix().toUpper();
if (qimage.isNull() && !ext.isEmpty())
{
if (ext == QString("JPEG") || ext == QString("JPG") || ext == QString("JPE"))
if (qimage.isNull() && !ext.isEmpty())
{
if (colorManage)
if (ext == QString("JPEG") || ext == QString("JPG") || ext == QString("JPE"))
{
qimage = loadWithDImg(path, &profile);
if (colorManage)
{
qimage = loadWithDImg(path, &profile);
}
else
// use jpegutils
{
JPEGUtils::loadJPEGScaled(qimage, path, d->storageSize());
}
failedAtJPEGScaled = qimage.isNull();
}
else
// use jpegutils
else if (ext == QString("PNG") ||
ext == QString("TIFF") ||
ext == QString("TIF"))
{
JPEGUtils::loadJPEGScaled(qimage, path, d->storageSize());
qimage = loadWithDImg(path, &profile);
failedAtDImg = qimage.isNull();
}
else if (ext == QString("PGF"))
{
// use pgf library to extract reduced version
PGFUtils::loadPGFScaled(qimage, path, d->storageSize());
failedAtPGFScaled = qimage.isNull();
}
failedAtJPEGScaled = qimage.isNull();
}
else if (ext == QString("PNG") ||
ext == QString("TIFF") ||
ext == QString("TIF"))
// Trying to load with dcraw: RAW files.
if (qimage.isNull())
{
qimage = loadWithDImg(path, &profile);
failedAtDImg = qimage.isNull();
if (KDcraw::loadEmbeddedPreview(qimage, path))
{
fromEmbeddedPreview = true;
profile = metadata.getIccProfile();
}
}
else if (ext == QString("PGF"))
if (qimage.isNull())
{
// use pgf library to extract reduced version
PGFUtils::loadPGFScaled(qimage, path, d->storageSize());
failedAtPGFScaled = qimage.isNull();
//TODO: Use DImg based loader instead?
KDcraw::loadHalfPreview(qimage, path);
}
}
// Trying to load with dcraw: RAW files.
if (qimage.isNull())
{
if (KDcraw::loadEmbeddedPreview(qimage, path))
// DImg-dependent loading methods: TIFF, PNG, everything supported by QImage
if (qimage.isNull() && !failedAtDImg)
{
fromEmbeddedPreview = true;
profile = metadata.getIccProfile();
qimage = loadWithDImg(path, &profile);
}
}
if (qimage.isNull())
{
//TODO: Use DImg based loader instead?
KDcraw::loadHalfPreview(qimage, path);
}
// DImg-dependent loading methods: TIFF, PNG, everything supported by QImage
if (qimage.isNull() && !failedAtDImg)
{
qimage = loadWithDImg(path, &profile);
}
// Try JPEG anyway
if (qimage.isNull() && !failedAtJPEGScaled)
{
// use jpegutils
JPEGUtils::loadJPEGScaled(qimage, path, d->storageSize());
}
// Try JPEG anyway
if (qimage.isNull() && !failedAtJPEGScaled)
{
// use jpegutils
JPEGUtils::loadJPEGScaled(qimage, path, d->storageSize());
}
// Try PGF anyway
if (qimage.isNull() && !failedAtPGFScaled)
{
// use jpegutils
PGFUtils::loadPGFScaled(qimage, path, d->storageSize());
// Try PGF anyway
if (qimage.isNull() && !failedAtPGFScaled)
{
// use jpegutils
PGFUtils::loadPGFScaled(qimage, path, d->storageSize());
}
}
if (qimage.isNull())
......@@ -541,7 +542,7 @@ ThumbnailImage ThumbnailCreator::createThumbnail(const ThumbnailInfo& info, cons
return ThumbnailImage();
}
qimage = scaleForStorage(qimage, isFace);
qimage = scaleForStorage(qimage);
if (colorManage && !profile.isNull())
{
......
......@@ -202,7 +202,7 @@ public:
*/
void store(const QString& path, const QImage& image) const;
void storeDetailThumbnail(const QString& path, const QRect& detailRect, const QImage& image, bool isFace = false) const;
void storeDetailThumbnail(const QString& path, const QRect& detailRect, const QImage& image) const;
/**
* Returns the last error that occurred.
......@@ -224,7 +224,7 @@ private:
void initialize();
ThumbnailImage createThumbnail(const ThumbnailInfo& info, const QRect& detailRect = QRect(), bool isFace = false) const;
ThumbnailImage createThumbnail(const ThumbnailInfo& info, const QRect& detailRect = QRect()) const;
QImage load(const QString& path, const QRect& rect, bool pregenerate) const;
QImage loadWithDImg(const QString& path, IccProfile* const profile) const;
......@@ -236,11 +236,11 @@ private:
int exifOrientation(const ThumbnailInfo& info, const DMetadata& metadata, bool fromEmbeddedPreview, bool fromDetail) const;
QImage exifRotate(const QImage& thumb, int orientation) const;
void store(const QString& path, const QImage& i, const QRect& rect, bool isFace = false) const;
void store(const QString& path, const QImage& i, const QRect& rect) const;
ThumbnailInfo makeThumbnailInfo(const QString& path, const QRect& rect) const;
QString identifierForDetail(const QString& path, const QRect& rect) const;
QImage scaleForStorage(const QImage& qimage, bool isFace) const;
QImage scaleForStorage(const QImage& qimage) const;
void storeInDatabase(const ThumbnailInfo& info, const ThumbnailImage& image) const;
DatabaseThumbnailInfo loadDatabaseThumbnailInfo(const ThumbnailInfo& info) const;
......
......@@ -906,7 +906,8 @@ QPixmap ThumbnailLoadThread::surrogatePixmap(const LoadingDescription& descripti
void ThumbnailLoadThread::storeDetailThumbnail(const QString& filePath, const QRect& detailRect, const QImage& image, bool isFace)
{
d->creator->storeDetailThumbnail(filePath, detailRect, image, isFace);
Q_UNUSED(isFace);
d->creator->storeDetailThumbnail(filePath, detailRect, image);
}
int ThumbnailLoadThread::storedSize() const
......
Markdown is supported
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