OSDN Git Service

kioslave: discard thumbnail from Exiv2 metadata if it is smaller than the requested...
authorIvailo Monev <xakepa10@gmail.com>
Sat, 7 May 2022 20:16:01 +0000 (23:16 +0300)
committerIvailo Monev <xakepa10@gmail.com>
Sat, 7 May 2022 20:16:01 +0000 (23:16 +0300)
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
kioslave/thumbnail/imagecreator.cpp
kioslave/thumbnail/imagecreator.h

index 3bdfac2..4b66109 100644 (file)
@@ -35,12 +35,18 @@ extern "C"
     }
 }
 
-bool ImageCreator::create(const QString &path, int, int, QImage &img)
+bool ImageCreator::create(const QString &path, int width, int height, QImage &img)
 {
     // use preview from Exiv2 metadata if possible
     KExiv2 exiv(path);
     img = exiv.preview();
 
+    // if the thumbnail from Exiv2 metadata is smaller than the request discard it, the preview in
+    // file properties dialog for example often requests large thumbnails
+    if (!img.isNull() && (img.width() < width || img.height() < height)) {
+        img = QImage();
+    }
+
     // create image preview otherwise
     if (img.isNull() && !img.load(path)) {
         return false;
index 23d0b27..c41d971 100644 (file)
@@ -26,7 +26,7 @@ class ImageCreator : public ThumbCreator
 {
 public:
     ImageCreator() {}
-    virtual bool create(const QString &path, int, int, QImage &img);
+    virtual bool create(const QString &path, int width, int height, QImage &img);
     virtual Flags flags() const;
     virtual QWidget *createConfigurationWidget();
     virtual void writeConfiguration(const QWidget *configurationWidget);