[PATCH] Frame large images with a small file size.



Hi

This has to do with one of my previous mails:
"[PATCH]Images of the same size are displayed with a different size in
the preview" (bug http://bugzilla.gnome.org/show_bug.cgi?id=153073 )

If that patch get accepted we also might add a frame to the images that
get displayed at the size of a thumbnail. The attached patch does this

Screenshot before patch:
http://bugzilla.gnome.org/attachment.cgi?id=34298&action=view
Screenshot after patch:
image-as-itself-with-frame.png

The patch is attached.

When making this patch I noticed that thumbnails that get stored in the
.thumbnail directory actually have a size of 128 and have a frame
included. (NOTE when I'm referring to size of an image it is the maximum
of the horizontal and the vertical size). If the zoom level is set to
"Normal Size" thumbnails have a size of 96 and one zoom level higher
they have a size of 144.

This means that the thumbnails always will need to get scaled when they
are shown. I would think it would be better to store thumbnails with a
size of 96 on disk.

Advantages of having thumbnails on disk of size 96
----------------------------------------------------
* Thumbnailing will be faster because thumbnail is smaller. (and also
some disk space will be saved). Since the number of computations downscaling depends on the number of pixels of the downscaled image theoretically a speedup with a factor (128/96)^2=1.77 should be possible

* At normal zoom level Nautilus will be snappier because it does not
have to downscale the image
* The thumbnail will look a bit sharper (less blurry) on normal zoom level, because it was not downscaled from 128 to 96. Look to the difference between 1024x768 and 320x240 image in http://ftp.haitsma.org/image-as-itself-with-frame.png

Disadvantages
-------------
* If you change from normal zoom level to a higher zoom level, the image
will all of sudden go from pretty sharp to a bit blurry.

* On higher zoom levels thumbnails will be a bit more blurry then with
the size 128

For me the advantages clearly outweigh the disadvantages. What do other
people think about this? Would a patch changing the thumbnail size get accepted?????

Jaap


NOTE the attached patch also includes the patch of "[PATCH]Images of the same size are displayed with a different size in
the preview" (bug http://bugzilla.gnome.org/show_bug.cgi?id=153073 )

NOTE2 I haven't filed a bug in bugzilla for the attached patch. Should I still do that?


Index: nautilus-icon-factory.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-icon-factory.c,v
retrieving revision 1.308
diff -u -p -r1.308 nautilus-icon-factory.c
--- nautilus-icon-factory.c	22 Nov 2004 15:24:36 -0000	1.308
+++ nautilus-icon-factory.c	29 Nov 2004 21:24:08 -0000
@@ -1103,6 +1103,7 @@ load_icon_file (const char    *filename,
 	int width, height, size;
 	double scale;
 	gboolean is_thumbnail;
+        gboolean add_frame = FALSE;
 
 	*scale_x = 1.0;
 	*scale_y = 1.0;
@@ -1142,8 +1143,14 @@ load_icon_file (const char    *filename,
 				width = gdk_pixbuf_get_width (pixbuf); 
 				height = gdk_pixbuf_get_height (pixbuf);
 				size = MAX (width, height);
-				if (size > NAUTILUS_ICON_SIZE_STANDARD + 5) {
-					base_size = size;
+                                if (size > NAUTILUS_ICON_SIZE_THUMBNAIL) {
+                                        add_frame=TRUE;
+                                }
+                                if (size >  nominal_size * NAUTILUS_ICON_SIZE_THUMBNAIL / NAUTILUS_ICON_SIZE_STANDARD) {
+                                        base_size = size * NAUTILUS_ICON_SIZE_STANDARD / NAUTILUS_ICON_SIZE_THUMBNAIL;
+                                }
+                                else if (size > NAUTILUS_ICON_SIZE_STANDARD) {
+					base_size = nominal_size;
 				} else {
 					/* Don't scale up small icons */
 					base_size = NAUTILUS_ICON_SIZE_STANDARD;
@@ -1161,6 +1168,9 @@ load_icon_file (const char    *filename,
 		}
 	}
 
+        if (add_frame){
+                nautilus_thumbnail_frame_image(&pixbuf);
+        }
 	return pixbuf;
 }
 
Index: nautilus-thumbnails.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-thumbnails.c,v
retrieving revision 1.51
diff -u -p -r1.51 nautilus-thumbnails.c
--- nautilus-thumbnails.c	28 Apr 2004 19:49:17 -0000	1.51
+++ nautilus-thumbnails.c	29 Nov 2004 21:24:13 -0000
@@ -225,30 +225,22 @@ nautilus_remove_thumbnail_for_file (cons
 	g_free (old_thumbnail_path);
 }
 
-/* routine to load an image from the passed-in path, and then embed it in
- * a frame if necessary
- */
-GdkPixbuf *
-nautilus_thumbnail_load_framed_image (const char *path)
+void
+nautilus_thumbnail_frame_image (GdkPixbuf **pixbuf)
 {
-	GdkPixbuf *pixbuf, *pixbuf_with_frame, *frame;
+	GdkPixbuf *pixbuf_with_frame, *frame;
 	gboolean got_frame_offsets;
 	char *frame_offset_str;
 	int left_offset, top_offset, right_offset, bottom_offset;
 	char c;
-	
-	pixbuf = gdk_pixbuf_new_from_file (path, NULL);
-	if (pixbuf == NULL) {
-		return NULL;
-	}
-	
+		
 	/* The pixbuf isn't already framed (i.e., it was not made by
 	 * an old Nautilus), so we must embed it in a frame.
 	 */
 
 	frame = nautilus_icon_factory_get_thumbnail_frame ();
 	if (frame == NULL) {
-		return pixbuf;
+		return;
 	}
 	
 	got_frame_offsets = FALSE;
@@ -269,13 +261,28 @@ nautilus_thumbnail_load_framed_image (co
 	}
 	
 	pixbuf_with_frame = eel_embed_image_in_frame
-		(pixbuf, frame,
+		(*pixbuf, frame,
 		 left_offset, top_offset, right_offset, bottom_offset);
-	g_object_unref (pixbuf);	
+	g_object_unref (*pixbuf);	
 
-	return pixbuf_with_frame;
+	*pixbuf=pixbuf_with_frame;
 }
 
+/* routine to load an image from the passed-in path, and then embed it in
+ * a frame if necessary
+ */
+GdkPixbuf *
+nautilus_thumbnail_load_framed_image (const char *path)
+{
+	GdkPixbuf *pixbuf;
+	
+	pixbuf = gdk_pixbuf_new_from_file (path, NULL);
+	if (pixbuf == NULL) {
+		return NULL;
+	}
+        nautilus_thumbnail_frame_image(&pixbuf);	
+        return pixbuf;
+}
 
 void
 nautilus_thumbnail_remove_from_queue (const char *file_uri)
Index: nautilus-thumbnails.h
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-thumbnails.h,v
retrieving revision 1.10
diff -u -p -r1.10 nautilus-thumbnails.h
--- nautilus-thumbnails.h	12 Mar 2003 14:29:01 -0000	1.10
+++ nautilus-thumbnails.h	29 Nov 2004 21:24:13 -0000
@@ -30,6 +30,7 @@
 
 /* Returns NULL if there's no thumbnail yet. */
 void       nautilus_create_thumbnail                (NautilusFile *file);
+void       nautilus_thumbnail_frame_image           (GdkPixbuf **pixbuf);
 GdkPixbuf *nautilus_thumbnail_load_framed_image     (const char   *path);
 void       nautilus_update_thumbnail_file_renamed   (const char   *old_file_uri,
 						     const char   *new_file_uri);


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