Index: libgthumb/gfile-utils.c
===================================================================
--- libgthumb/gfile-utils.c	(revision 2400)
+++ libgthumb/gfile-utils.c	(working copy)
@@ -21,10 +21,14 @@
  */
 
 
+#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <glib.h>
 
+#include "preferences.h"
+#include "glib-utils.h"
+#include "gconf-utils.h"
 #include "gfile-utils.h"
 
 
@@ -94,11 +98,11 @@
 	uri = gfile_get_uri (file);
 	
 	if (err == NULL)
-		warning = g_strdup_printf ("%s: file %s\n", msg, uri);
+		warning = g_strdup_printf ("%s: file %s", msg, uri);
 	else
-		warning = g_strdup_printf ("%s: file %s: %s\n", msg, uri, err->message);
+		warning = g_strdup_printf ("%s: file %s: %s", msg, uri, err->message);
 	
-	g_warning (warning);
+	g_warning ("%s\n", warning);
 	
         g_free (uri);
         g_free (warning);
@@ -199,6 +203,132 @@
 }
 
 
+/* Be careful: result must be g_free'd  */
+char *
+gfile_get_filename_extension (GFile *file)
+{
+	char *basename;
+	char *last_dot;
+	char *extension;
+
+	basename = g_file_get_basename (file);
+	
+	g_assert (basename != NULL);
+	
+	last_dot = strrchr (basename, '.');
+	if (last_dot == NULL)
+		return NULL;
+
+	extension = g_strdup (last_dot + 1);
+	
+	g_free (basename);
+	
+	return extension;
+}
+
+
+const char*
+gfile_get_file_mime_type (GFile      *file,
+                          gboolean    fast_file_type)
+{
+	const char *value;
+	const char *result = NULL;
+	GFileInfo  *info;
+	GError     *error = NULL;
+ 
+	g_assert (file != NULL);
+	
+	info = g_file_query_info (file,
+				  fast_file_type ?
+				  G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE :
+				  G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
+				  G_FILE_QUERY_INFO_NONE, 
+				  NULL, 
+				  &error);
+        if (info != NULL) {
+        	if (fast_file_type)
+        		value = g_file_info_get_attribute_string (info, 
+        				                          G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE);
+        	else
+        		value = g_file_info_get_content_type (info);
+        	
+		/* 
+		 * If the file content is determined to be binary data (octet-stream), check for 
+		 * HDR file types, which are not well represented in the freedesktop mime database 
+		 * currently. This section can be purged when they are. This is an unpleasant hack. 
+		 * Some file extensions may be missing here; please file a bug if they are. 
+		 */
+		if (strcmp (value, "application/octet-stream") == 0) {
+	
+			char* extension;
+			
+			extension = gfile_get_filename_extension (file);
+			
+			if (extension != NULL) {
+				if (   !strcasecmp (extension, "exr")	/* OpenEXR format */
+				    || !strcasecmp (extension, "hdr")	/* Radiance rgbe */
+				    || !strcasecmp (extension, "pic"))	/* Radiance rgbe */
+					value = "image/x-hdr";
+				
+				g_free (extension);
+			}
+		}
+        	
+
+        	result = get_static_string  (value);
+        }
+        else {
+                gfile_warning ("Could not get content type", file, error);
+                g_clear_error (&error);
+        }
+
+        g_object_unref (info);
+	
+	return result;
+}
+
+
+static gboolean
+_gfile_image_is_type (GFile      *file,
+	             const char *mime_type,
+	             gboolean    fast_file_type)
+{
+	const char *result;
+	
+	result = gfile_get_file_mime_type (file, fast_file_type);
+	
+	if (result == NULL)
+		return FALSE;
+	
+	return (strcmp (result, mime_type) == 0);
+}
+
+
+static gboolean
+_gfile_image_is_type__gconf_file_type (GFile      *file,
+			               const char *mime_type)
+{
+	return _gfile_image_is_type (file, 
+				     mime_type, 
+				     ! gfile_is_local (file) 
+			             || eel_gconf_get_boolean (PREF_FAST_FILE_TYPE, TRUE));
+}
+
+
+gboolean
+gfile_image_is_jpeg (GFile *file)
+{
+	return _gfile_image_is_type__gconf_file_type (file, "image/jpeg");
+}
+
+
+gboolean
+gfile_image_is_gif (GFile *file)
+{
+	return _gfile_image_is_type__gconf_file_type (file, "image/gif");
+}
+
+
 static gboolean
 gfile_is_filetype (GFile      *file,
 		   GFileType   file_type)
@@ -212,7 +342,7 @@
 
 	info = g_file_query_info (file, 
 			          G_FILE_ATTRIBUTE_STANDARD_TYPE, 
-			          0, 
+			          G_FILE_QUERY_INFO_NONE, 
 			          NULL, 
 			          &error);
 	if (error == NULL) {
@@ -250,11 +380,15 @@
 	goffset    size = 0;
 	GError    *err = NULL;
 
-	//FIXME: shouldn't we get rid of this test and fix the callers instead
+	//FIXME: shouldn't we get rid of this test and fix the callers instead?
 	if (file == NULL)
 		return 0;
 	
-        info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_SIZE, 0, NULL, &err);
+        info = g_file_query_info (file, 
+        		          G_FILE_ATTRIBUTE_STANDARD_SIZE, 
+        		          G_FILE_QUERY_INFO_NONE, 
+        		          NULL, 
+        		          &err);
         if (err == NULL) {
                 size = g_file_info_get_size (info);
         }
@@ -272,7 +406,7 @@
 /* Directory utils */
 
 static gboolean
-make_directory_tree (GFile    *dir,
+_gfile_make_directory_tree (GFile    *dir,
 		     mode_t    mode,
 		     GError  **error)
 {
@@ -281,7 +415,7 @@
 
 	parent = g_file_get_parent (dir);
 	if (parent != NULL) {
-		success = make_directory_tree (parent, mode, error);
+		success = _gfile_make_directory_tree (parent, mode, error);
 		g_object_unref (parent);
 		if (! success)
 			return FALSE;
@@ -312,14 +446,14 @@
 {
 	GError *priv_error = NULL;
 
-	//FIXME: shouldn't we get rid of this test and fix the callers instead
+	//FIXME: shouldn't we get rid of this test and fix the callers instead?
 	if (dir == NULL)
 		return FALSE;
 
 	if (error == NULL)
 		error = &priv_error;
 
-	if (! make_directory_tree (dir, mode, error)) {
+	if (! _gfile_make_directory_tree (dir, mode, error)) {
 		
 		gfile_warning ("could not create directory", dir, *error);
 		if (priv_error != NULL)
@@ -384,7 +518,7 @@
 #define MAX_TEMP_FOLDER_TO_TRY  2
 
 static GFile *
-ith_temp_folder_to_try (int n)
+_gfile_ith_temp_folder_to_try (int n)
 {
 	GFile *dir = NULL;
 	
@@ -436,7 +570,7 @@
 		GFile    *folder;
 		guint64   size;
 
-		folder = ith_temp_folder_to_try (i);
+		folder = _gfile_ith_temp_folder_to_try (i);
 		size = gfile_get_destination_free_space (folder);
 		if (max_size < size) {
 			max_size = size;
@@ -464,7 +598,7 @@
 
 
 static gboolean
-delete_directory_recursive (GFile   *dir,
+_gfile_delete_directory_recursive (GFile   *dir,
 			    GError **error)
 {
 	GFileEnumerator *file_enum;
@@ -486,7 +620,7 @@
 
 		switch (g_file_info_get_file_type (info)) {
 		case G_FILE_TYPE_DIRECTORY:
-			if (! delete_directory_recursive (child, error))
+			if (! _gfile_delete_directory_recursive (child, error))
 				error_occurred = TRUE;
 			break;
 		default:
@@ -514,7 +648,7 @@
 	gboolean   result;
 	GError    *error = NULL;
 
-	result = delete_directory_recursive (dir, &error);
+	result = _gfile_delete_directory_recursive (dir, &error);
 	if (! result) {
 		gfile_warning ("Cannot delete directory", dir, error);
 		g_clear_error (&error);
@@ -526,14 +660,13 @@
 
 /* Xfer */
 
-
-/* empty functions */
 static void _empty_file_progress_cb  (goffset current_num_bytes,
 				      goffset total_num_bytes,
 				      gpointer user_data)
 {
 }
 
+
 gboolean
 gfile_xfer (GFile    *sfile,
 	    GFile    *dfile,
Index: libgthumb/gfile-utils.h
===================================================================
--- libgthumb/gfile-utils.h	(revision 2400)
+++ libgthumb/gfile-utils.h	(working copy)
@@ -66,6 +66,10 @@
                                                 ...);
 
 gboolean      gfile_is_local                   (GFile      *file);
+const char*   gfile_get_file_mime_type         (GFile      *file,
+                                                gboolean    fast_file_type);
+gboolean      gfile_image_is_jpeg              (GFile      *file);
+gboolean      gfile_image_is_gif               (GFile      *file);
 gboolean      gfile_path_is_file               (GFile      *file);
 gboolean      gfile_path_is_dir                (GFile      *file);
 goffset       gfile_get_file_size              (GFile      *file);
Index: libgthumb/file-utils.c
===================================================================
--- libgthumb/file-utils.c	(revision 2400)
+++ libgthumb/file-utils.c	(working copy)
@@ -807,99 +807,27 @@
 }
 
 
-static char*
-get_sample_name (const char *filename)
-{
-	const char *ext;
-
-	ext = get_extension (filename);
-	if (ext == NULL)
-		return NULL;
-
-	return g_strconcat ("a", get_extension (filename), NULL);
-}
-
-
 const char*
-get_file_mime_type (const char *filename,
+get_file_mime_type (const char *path,
 		    gboolean    fast_file_type)
 {
-	const char *result = NULL;
-	const char *extension;
-
-	if (filename == NULL)
+	GFile      *file;
+	const char *result;
+	
+	if (path == NULL)
 		return NULL;
 
-	if (fast_file_type) {
-		char *sample_name;
-		char *n1;
-
-		sample_name = get_sample_name (filename);
-		if (sample_name != NULL) {
-			n1 = g_filename_to_utf8 (sample_name, -1, 0, 0, 0);
-			if (n1 != NULL) {
-				char *n2 = g_utf8_strdown (n1, -1);
-				char *n3 = g_filename_from_utf8 (n2, -1, 0, 0, 0);
-				if (n3 != NULL)
-					result = gnome_vfs_mime_type_from_name_or_default (file_name_from_path (n3), NULL);
-				g_free (n3);
-				g_free (n2);
-				g_free (n1);
-			}
+	file = gfile_new (path);
 
-			g_free (sample_name);
-		}
-	} 
-	else {
-		if (uri_scheme_is_file (filename))
-			filename = get_file_path_from_uri (filename);
-		result = gnome_vfs_get_file_mime_type (filename, NULL, FALSE);
-	}
+	result = gfile_get_file_mime_type (file, fast_file_type);
 
-	result = get_static_string (result);
-
-	/* Check files with special or problematic extensions */
-	extension = get_filename_extension (filename);
-	if (extension != NULL) {
-
-		/* Raw NEF files are sometimes mis-recognized as tiff files. Fix that. */
-		if (!strcmp_null_tolerant (result, "image/tiff") && 
-		    !strcasecmp (extension, "nef"))
-			return "image/x-nikon-nef";
-
-		/* Raw CR2 files are sometimes mis-recognized as tiff files. Fix that. */
-		if (!strcmp_null_tolerant (result, "image/tiff") && 
-		    !strcasecmp (extension, "cr2"))
-			return "image/x-canon-cr2";
-
-		/* Check unrecognized binary types for special types that are not
-		   handled correctly in the normal mime databases. */
-
-		if ((result == NULL) || 
-		    (strcmp_null_tolerant (result, "application/octet-stream") == 0)) {
-
-			/* If the file extension is not recognized, or the content is
-			   determined to be binary data (octet-stream), check for HDR file
-			   types, which are not well represented in the freedesktop mime
-			   database currently. This section can be purged when they are.
-			   This is an unpleasant hack. Some file extensions
-			   may be missing here; please file a bug if they are. */
-			if (   !strcasecmp (extension, "exr")	/* OpenEXR format */
-			    || !strcasecmp (extension, "hdr")	/* Radiance rgbe */
-			    || !strcasecmp (extension, "pic"))	/* Radiance rgbe */
-				return "image/x-hdr";
-
-			/* Bug 329072: gnome-vfs doesn't recognize pcx files.
-			   This is the work-around until bug 329072 is fixed. */
-			if (strcasecmp (extension, "pcx") == 0)
-				return "image/x-pcx";
-		}
-	}
+	g_object_unref (file);
 
 	return result;
 }
 
 
+
 gboolean
 mime_type_is (const char *mime_type,
 	      const char *value)
@@ -909,27 +837,18 @@
 
 
 gboolean
-image_is_type (const char *uri,
-	       const char *type,
-	       gboolean    fast_file_type)
+image_is_jpeg (const char *path)
 {
-	const char *result = get_file_mime_type (uri, fast_file_type);
-	return (strcmp_null_tolerant (result, type) == 0);
-}
-
-
-static gboolean
-image_is_type__gconf_file_type (const char *uri,
-			        const char *type)
-{
-	return image_is_type (uri, type, ! is_local_file (uri) || eel_gconf_get_boolean (PREF_FAST_FILE_TYPE, TRUE));
-}
-
+	GFile    *file;
+	gboolean  result;
+	
+	file = gfile_new (path);
+	
+	result = image_is_jpeg (file);
+	
+	g_object_unref (file);
 
-gboolean
-image_is_jpeg (const char *name)
-{
-	return image_is_type__gconf_file_type (name, "image/jpeg");
+	return result;
 }
 
 
@@ -964,9 +883,18 @@
 
 
 gboolean
-image_is_gif (const char *name)
+image_is_gif (const char *path)
 {
-	return image_is_type__gconf_file_type (name, "image/gif");
+	GFile    *file;
+	gboolean  result;
+	
+	file = gfile_new (path);
+	
+	result = gfile_image_is_gif (file);
+	
+	g_object_unref (file);
+
+	return result;
 }
 
 
Index: src/catalog-web-exporter.c
===================================================================
--- src/catalog-web-exporter.c	(revision 2400)
+++ src/catalog-web-exporter.c	(working copy)
@@ -2664,10 +2664,10 @@
 	copy_done = gfile_copy (sfile, dfile);
 
 	if (copy_done) {
-		char *uri;
-		uri = gfile_get_uri (dfile);
+		if (gfile_image_is_jpeg (dfile)) {
+			char *uri;
+			uri = gfile_get_uri (dfile);
 		
-		if (image_is_jpeg (uri)) {
 			GthTransform  transform;
 		
 			FileData *fd;
@@ -2682,8 +2682,8 @@
 			}
 
 			file_data_unref (fd);
+			g_free (uri);
 		}
-		g_free (uri);
 	}
 	
 	g_object_unref (sfile);

