summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Volkov <[email protected]>2017-05-15 13:29:44 +0300
committerAlexander Volkov <[email protected]>2017-06-03 14:20:19 +0300
commitb5e4e830bae2928b54a52fca26c3009e96fe2c56 (patch)
tree3ebe5597848cb0b8a694e698a90a2883eecbc31e
parentd0842dc57e7e16c1724676d35228ecfaf52488e2 (diff)
Don't upscale jpeg images when creating thumbnails
BUG: 379817 REVIEW: 130129
-rw-r--r--thumbnail/jpegcreator.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/thumbnail/jpegcreator.cpp b/thumbnail/jpegcreator.cpp
index e4c7f0e..d20ba98 100644
--- a/thumbnail/jpegcreator.cpp
+++ b/thumbnail/jpegcreator.cpp
@@ -43,9 +43,10 @@ bool JpegCreator::create(const QString &path, int width, int height, QImage &ima
QImageReader imageReader(path);
const QSize imageSize = imageReader.size();
- const QSize thumbnailSize = imageSize.isValid() ? imageSize.scaled(width, height, Qt::KeepAspectRatio)
- : QSize(width, height);
- imageReader.setScaledSize(thumbnailSize); // fast downscaling
+ if (imageSize.isValid() && (imageSize.width() > width || imageSize.height() > height)) {
+ const QSize thumbnailSize = imageSize.scaled(width, height, Qt::KeepAspectRatio);
+ imageReader.setScaledSize(thumbnailSize); // fast downscaling
+ }
imageReader.setQuality(0);
JpegCreatorSettings* settings = JpegCreatorSettings::self();