X-Git-Url: https://git.street.me.uk/andy/viking.git/blobdiff_plain/65c1e0b03ad3fa552f965ace461be98ebd4e9fc1..75ee0e75ba122a83c6f10126a778c103170dc615:/src/thumbnails.c diff --git a/src/thumbnails.c b/src/thumbnails.c index dc8f8a9f..bd97f312 100644 --- a/src/thumbnails.c +++ b/src/thumbnails.c @@ -55,7 +55,6 @@ #undef MIN /* quit yer whining, gcc */ #undef MAX -#include /* for realpath() */ #ifndef MAX /* We need MAX macro and some system does not offer it */ #define MAX(a,b) (((a)>(b))?(a):(b)) @@ -66,8 +65,6 @@ #ifdef WINDOWS #define THUMB_DIR "\\THUMBNAILS\\" /* viking maps default viking\maps */ #define THUMB_SUB_DIR "normal\\" -#define realpath(X,Y) _fullpath(Y,X,MAX_PATH) - #else #define THUMB_DIR "/.thumbnails/" #define THUMB_SUB_DIR "normal/" @@ -122,7 +119,7 @@ GdkPixbuf *a_thumbnails_scale_pixbuf(GdkPixbuf *src, int max_w, int max_h) if (w <= max_w && h <= max_h) { - gdk_pixbuf_ref(src); + g_object_ref ( G_OBJECT ( src ) ); return src; } else @@ -142,14 +139,20 @@ GdkPixbuf *a_thumbnails_scale_pixbuf(GdkPixbuf *src, int max_w, int max_h) static GdkPixbuf *child_create_thumbnail(const gchar *path) { - GdkPixbuf *image; + GdkPixbuf *image, *tmpbuf; image = gdk_pixbuf_new_from_file(path, NULL); + if (!image) + return NULL; + + tmpbuf = gdk_pixbuf_apply_embedded_orientation(image); + g_object_unref(G_OBJECT(image)); + image = tmpbuf; if (image) { GdkPixbuf *thumb = save_thumbnail(path, image); - gdk_pixbuf_unref ( image ); + g_object_unref ( G_OBJECT ( image ) ); return thumb; } @@ -161,6 +164,7 @@ static GdkPixbuf *save_thumbnail(const char *pathname, GdkPixbuf *full) struct stat info; gchar *path; int original_width, original_height; + const gchar* orientation; GString *to; char *md5, *swidth, *sheight, *ssize, *smtime, *uri; mode_t old_mask; @@ -172,6 +176,8 @@ static GdkPixbuf *save_thumbnail(const char *pathname, GdkPixbuf *full) thumb = a_thumbnails_scale_pixbuf(full, PIXMAP_THUMB_SIZE, PIXMAP_THUMB_SIZE); + orientation = gdk_pixbuf_get_option (full, "orientation"); + original_width = gdk_pixbuf_get_width(full); original_height = gdk_pixbuf_get_height(full); @@ -208,6 +214,7 @@ static GdkPixbuf *save_thumbnail(const char *pathname, GdkPixbuf *full) "tEXt::Thumb::MTime", smtime, "tEXt::Thumb::URI", uri, "tEXt::Software", PROJECT, + "tEXt::Software::Orientation", orientation ? orientation : "0", NULL); umask(old_mask); @@ -279,7 +286,7 @@ GdkPixbuf *a_thumbnails_get(const gchar *pathname) goto out; err: if (thumb) - gdk_pixbuf_unref(thumb); + g_object_unref ( G_OBJECT ( thumb ) ); thumb = NULL; out: g_free(path); @@ -295,7 +302,7 @@ static char *pathdup(const char *path) g_return_val_if_fail(path != NULL, NULL); - if (realpath(path, real)) + if (file_realpath(path, real)) return g_strdup(real); return g_strdup(path);