/*
* Geeqie
* (C) 2006 John Ellis
- * Copyright (C) 2008 - 2009 The Geeqie Team
+ * Copyright (C) 2008 - 2012 The Geeqie Team
*
* Author: John Ellis
*
static void thumb_loader_std_error_cb(ImageLoader *il, gpointer data);
static gint thumb_loader_std_setup(ThumbLoaderStd *tl, FileData *fd);
-static gint thumb_loader_std_setup_path(ThumbLoaderStd *tl, const gchar *path);
ThumbLoaderStd *thumb_loader_std_new(gint width, gint height)
{
if (!tl->fd->exif_orientation)
{
- tl->fd->exif_orientation = metadata_read_int(tl->fd, "Exif.Image.Orientation", EXIF_ORIENTATION_TOP_LEFT);
+ tl->fd->exif_orientation = metadata_read_int(tl->fd, ORIENTATION_KEY, EXIF_ORIENTATION_TOP_LEFT);
}
if (tl->fd->exif_orientation != EXIF_ORIENTATION_TOP_LEFT)
if (sw > cache_w || sh > cache_h || shrunk)
{
gint thumb_w, thumb_h;
+ struct stat st;
if (pixbuf_scale_aspect(cache_w, cache_h, sw, sh,
&thumb_w, &thumb_h))
g_object_ref(G_OBJECT(pixbuf_thumb));
}
- thumb_loader_std_save(tl, pixbuf_thumb);
+ /* do not save the thumbnail if the source file has changed meanwhile -
+ the thumbnail is most probably broken */
+ if (stat_utf8(tl->fd->path, &st) &&
+ tl->source_mtime == st.st_mtime &&
+ tl->source_size == st.st_size)
+ {
+ thumb_loader_std_save(tl, pixbuf_thumb);
+ }
}
}
else if (tl->cache_hit &&
if (!tl->thumb_path_local)
{
tl->thumb_path = thumb_loader_std_cache_path(tl, TRUE, NULL, FALSE);
- if (isfile(tl->thumb_path) && thumb_loader_std_setup_path(tl, tl->thumb_path))
+ if (isfile(tl->thumb_path))
{
- tl->thumb_path_local = TRUE;
- return TRUE;
+ FileData *fd = file_data_new_no_grouping(tl->thumb_path);
+ if (thumb_loader_std_setup(tl, fd))
+ {
+ file_data_unref(fd);
+ tl->thumb_path_local = TRUE;
+ return TRUE;
+ }
+ file_data_unref(fd);
}
g_free(tl->thumb_path);
return FALSE;
}
-static gboolean thumb_loader_std_setup_path(ThumbLoaderStd *tl, const gchar *path)
-{
- FileData *fd = file_data_new_simple(path);
- gboolean ret = thumb_loader_std_setup(tl, fd);
- file_data_unref(fd);
- return ret;
-}
-
/*
* Note: Currently local_cache only specifies where to save a _new_ thumb, if
* a valid existing thumb is found anywhere the local thumb will not be created.
tl->thumb_path_local = FALSE;
found = isfile(tl->thumb_path);
- if (found && thumb_loader_std_setup_path(tl, tl->thumb_path)) return TRUE;
+ if (found)
+ {
+ FileData *fd = file_data_new_no_grouping(tl->thumb_path);
+ if (thumb_loader_std_setup(tl, fd))
+ {
+ file_data_unref(fd);
+ return TRUE;
+ }
+ file_data_unref(fd);
+ }
if (thumb_loader_std_fail_check(tl) ||
!thumb_loader_std_next_source(tl, found))
GdkPixbuf *pixbuf;
gboolean valid = FALSE;
- /* this function is called on success, so the pixbuf should not be a fallback*/
- pixbuf = thumb_loader_std_get_pixbuf(tv->tl);
+ /* get the original thumbnail pixbuf (unrotated, with original options)
+ this is called from image_loader done callback, so tv->tl->il must exist*/
+ pixbuf = image_loader_get_pixbuf(tv->tl->il);
if (pixbuf)
{
const gchar *uri;
}
}
}
-
- g_object_unref(pixbuf);
+ else
+ {
+ DEBUG_1("invalid image found in std cache: %s", tv->path);
+ }
}
thumb_loader_std_thumb_file_validate_finish(tv, valid);
tv->func_valid = func_valid;
tv->data = data;
- if (!thumb_loader_std_setup_path(tv->tl, thumb_path))
+ FileData *fd = file_data_new_no_grouping(thumb_path);
+ if (!thumb_loader_std_setup(tv->tl, fd))
{
tv->idle_id = g_idle_add(thumb_loader_std_thumb_file_validate_idle_cb, tv);
}
tv->idle_id = 0;
}
+ file_data_unref(fd);
return tv->tl;
}
TMaintMove *tm = data;
GdkPixbuf *pixbuf;
- /* this function is called on success, so the pixbuf should not be a fallback*/
- pixbuf = thumb_loader_std_get_pixbuf(tm->tl);
+ /* get the original thumbnail pixbuf (unrotated, with original options)
+ this is called from image_loader done callback, so tm->tl->il must exist*/
+ pixbuf = image_loader_get_pixbuf(tm->tl->il);
if (pixbuf)
{
const gchar *uri;
tm->tl->cache_enable = TRUE;
tm->tl->cache_hit = FALSE;
tm->tl->cache_local = FALSE;
-
file_data_unref(tm->tl->fd);
- tm->tl->fd = file_data_new_simple(tm->dest);
+ tm->tl->fd = file_data_new_group(tm->dest);
tm->tl->source_mtime = strtol(mtime_str, NULL, 10);
pathl = path_from_utf8(tm->tl->fd->path);
DEBUG_1("thumb move unlink: %s", tm->thumb_path);
unlink_file(tm->thumb_path);
- g_object_unref(pixbuf);
}
thumb_std_maint_move_step(tm);