[gnome-photos/wip/rishi/thumbnailer: 2/2] thumbnailer: Don't upscale thumbnails



commit 85026c58c40967aa9cedbe45fc58d11e8bbadd87
Author: Debarshi Ray <debarshir gnome org>
Date:   Mon Feb 20 08:36:41 2017 +0100

    thumbnailer: Don't upscale thumbnails

 src/photos-thumbnailer.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/src/photos-thumbnailer.c b/src/photos-thumbnailer.c
index 9366f81..7d4b42f 100644
--- a/src/photos-thumbnailer.c
+++ b/src/photos-thumbnailer.c
@@ -280,13 +280,13 @@ photos_thumbnailer_generate_thumbnail_process (GObject *source_object, GAsyncRes
   pixbuf_height = gdk_pixbuf_get_height (data->pixbuf_thumbnail);
   pixbuf_width = gdk_pixbuf_get_width (data->pixbuf_thumbnail);
 
-  if (pixbuf_height > pixbuf_width && pixbuf_height != data->thumbnail_size)
+  if (pixbuf_height > pixbuf_width && pixbuf_height > data->thumbnail_size)
     {
       zoom = (gdouble) data->thumbnail_size / (gdouble) pixbuf_height;
       pixbuf_zoomed_height = data->thumbnail_size;
       pixbuf_zoomed_width = (gint) (zoom * (gdouble) pixbuf_width + 0.5);
     }
-  else if (pixbuf_height <= pixbuf_width && pixbuf_width != data->thumbnail_size)
+  else if (pixbuf_height <= pixbuf_width && pixbuf_width > data->thumbnail_size)
     {
       zoom = (gdouble) data->thumbnail_size / (gdouble) pixbuf_width;
       pixbuf_zoomed_height = (gint) (zoom * (gdouble) pixbuf_height + 0.5);
@@ -429,6 +429,11 @@ photos_thumbnailer_generate_thumbnail_pipeline (GObject *source_object, GAsyncRe
           load_width = (gint) data->original_width;
         }
     }
+  else if (data->original_height < data->thumbnail_size && data->original_width < data->thumbnail_size)
+    {
+      load_height = (gint) data->original_height;
+      load_width = (gint) data->original_width;
+    }
   else
     {
       load_height = data->thumbnail_size;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]