From d3709b893f6ba8657759ad981af79ac3740e1c71 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sat, 1 Sep 2012 19:42:11 +0200 Subject: Fix bug in thumbnail generation when used with 'feh .' It used to save the thumbnail for /path/to/./pmage.png, now it is always /path/to/image.png --- src/thumbnail.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/thumbnail.c') diff --git a/src/thumbnail.c b/src/thumbnail.c index b26dc7f..c1081f3 100644 --- a/src/thumbnail.c +++ b/src/thumbnail.c @@ -596,6 +596,9 @@ char *feh_thumbnail_get_name_uri(char *name) /* FIXME: add support for ~, need to investigate if it's expanded somewhere else before adding (unecessary) code */ if (name[0] != '/') { + /* work around /some/path/./image.ext */ + if ((strncmp(name, "./", 2)) == 0) + name += 2; cwd = getcwd(NULL, 0); uri = estrjoin("/", "file:/", cwd, name, NULL); free(cwd); -- cgit v1.2.3 From 3e4d9f98c3c154b9c9aa6082b3d498e59dcb1e2e Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Wed, 12 Sep 2012 20:24:42 +0200 Subject: show error message if -o / -O failed to save image --- ChangeLog | 1 + src/index.c | 8 ++++++-- src/thumbnail.c | 8 ++++++-- 3 files changed, 13 insertions(+), 4 deletions(-) (limited to 'src/thumbnail.c') diff --git a/ChangeLog b/ChangeLog index 53b6457..4f12946 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,7 @@ git HEAD was used for thumbnail name generation. Now it is always '/path/to/image.png' * Show error message if lossless rotate / flip failed on non-JPEG image + * Show error message if -O / -o failed to save image Tue, 28 Aug 2012 11:46:19 +0200 Daniel Friesel diff --git a/src/index.c b/src/index.c index 023cba0..e5a93a4 100644 --- a/src/index.c +++ b/src/index.c @@ -35,6 +35,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. /* TODO s/bit/lot */ void init_index_mode(void) { + Imlib_Load_Error err; Imlib_Image im_main; Imlib_Image im_temp; int w = 800, h = 600, ww = 0, hh = 0, www, hhh, xxx, yyy; @@ -326,8 +327,11 @@ void init_index_mode(void) else strncpy(output_buf, opt.output_file, 1024); - gib_imlib_save_image(im_main, output_buf); - if (opt.verbose) { + ungib_imlib_save_image_with_error_return(im_main, output_buf, &err); + if (err) { + weprintf("Cannot save image to %s", output_buf); + } + else if (opt.verbose) { int tw, th; tw = gib_imlib_image_get_width(im_main); diff --git a/src/thumbnail.c b/src/thumbnail.c index c1081f3..c622b07 100644 --- a/src/thumbnail.c +++ b/src/thumbnail.c @@ -55,6 +55,7 @@ void init_thumbnail_mode(void) int max_column_w = 0; */ + Imlib_Load_Error err; Imlib_Image im_temp; int ww = 0, hh = 0, www, hhh, xxx, yyy; int orig_w, orig_h; @@ -381,8 +382,11 @@ void init_thumbnail_mode(void) snprintf(output_buf, 1024, "%s/%s", opt.output_dir, opt.output_file); else strncpy(output_buf, opt.output_file, 1024); - gib_imlib_save_image(td.im_main, output_buf); - if (opt.verbose) { + ungib_imlib_save_image_with_error_return(td.im_main, output_buf, &err); + if (err) { + weprintf("Cannot save image to %s", output_buf); + } + else if (opt.verbose) { int tw, th; tw = gib_imlib_image_get_width(td.im_main); -- cgit v1.2.3 From 290b5964ef857ea52d85edf846edd82392d9a716 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Wed, 12 Sep 2012 20:46:15 +0200 Subject: print imlib2 error strings when save failed --- src/feh.h | 1 + src/imlib.c | 102 ++++++++++++++++++++++++++++++-------------------------- src/index.c | 2 +- src/slideshow.c | 2 +- src/thumbnail.c | 2 +- 5 files changed, 58 insertions(+), 51 deletions(-) (limited to 'src/thumbnail.c') diff --git a/src/feh.h b/src/feh.h index 2202617..cd730e9 100644 --- a/src/feh.h +++ b/src/feh.h @@ -157,6 +157,7 @@ void feh_display_status(char stat); void real_loadables_mode(int loadable); void feh_reload_image(winwidget w, int resize, int force_new); void feh_filelist_image_remove(winwidget winwid, char do_delete); +void feh_imlib_print_load_error(char *file, winwidget w, Imlib_Load_Error err); void slideshow_save_image(winwidget win); void ungib_imlib_save_image_with_error_return(Imlib_Image im, char *file, Imlib_Load_Error * error_return); diff --git a/src/imlib.c b/src/imlib.c index d89a5a4..3ffc538 100644 --- a/src/imlib.c +++ b/src/imlib.c @@ -155,6 +155,57 @@ void ungib_imlib_save_image_with_error_return(Imlib_Image im, char *file, imlib_save_image_with_error_return(file, error_return); } +void feh_imlib_print_load_error(char *file, winwidget w, Imlib_Load_Error err) +{ + if (err == IMLIB_LOAD_ERROR_OUT_OF_FILE_DESCRIPTORS) + eprintf("%s - Out of file descriptors while loading", file); + else if (!opt.quiet || w) { + switch (err) { + case IMLIB_LOAD_ERROR_FILE_DOES_NOT_EXIST: + im_weprintf(w, "%s - File does not exist", file); + break; + case IMLIB_LOAD_ERROR_FILE_IS_DIRECTORY: + im_weprintf(w, "%s - Directory specified for image filename", file); + break; + case IMLIB_LOAD_ERROR_PERMISSION_DENIED_TO_READ: + im_weprintf(w, "%s - No read access", file); + break; + case IMLIB_LOAD_ERROR_UNKNOWN: + case IMLIB_LOAD_ERROR_NO_LOADER_FOR_FILE_FORMAT: + im_weprintf(w, "%s - No Imlib2 loader for that file format", file); + break; + case IMLIB_LOAD_ERROR_PATH_TOO_LONG: + im_weprintf(w, "%s - Path specified is too long", file); + break; + case IMLIB_LOAD_ERROR_PATH_COMPONENT_NON_EXISTANT: + im_weprintf(w, "%s - Path component does not exist", file); + break; + case IMLIB_LOAD_ERROR_PATH_COMPONENT_NOT_DIRECTORY: + im_weprintf(w, "%s - Path component is not a directory", file); + break; + case IMLIB_LOAD_ERROR_PATH_POINTS_OUTSIDE_ADDRESS_SPACE: + im_weprintf(w, "%s - Path points outside address space", file); + break; + case IMLIB_LOAD_ERROR_TOO_MANY_SYMBOLIC_LINKS: + im_weprintf(w, "%s - Too many levels of symbolic links", file); + break; + case IMLIB_LOAD_ERROR_OUT_OF_MEMORY: + im_weprintf(w, "While loading %s - Out of memory", file); + break; + case IMLIB_LOAD_ERROR_PERMISSION_DENIED_TO_WRITE: + im_weprintf(w, "%s - Cannot write to directory", file); + break; + case IMLIB_LOAD_ERROR_OUT_OF_DISK_SPACE: + im_weprintf(w, "%s - Cannot write - out of disk space", file); + break; + default: + im_weprintf(w, "While loading %s - Unknown error (%d)", + file, err); + break; + } + } +} + int feh_load_image(Imlib_Image * im, feh_file * file) { Imlib_Load_Error err; @@ -208,53 +259,7 @@ int feh_load_image(Imlib_Image * im, feh_file * file) fputs("\n", stdout); reset_output = 1; } - if (err == IMLIB_LOAD_ERROR_OUT_OF_FILE_DESCRIPTORS) - eprintf("%s - Out of file descriptors while loading", file->filename); - else if (!opt.quiet) { - switch (err) { - case IMLIB_LOAD_ERROR_FILE_DOES_NOT_EXIST: - weprintf("%s - File does not exist", file->filename); - break; - case IMLIB_LOAD_ERROR_FILE_IS_DIRECTORY: - weprintf("%s - Directory specified for image filename", file->filename); - break; - case IMLIB_LOAD_ERROR_PERMISSION_DENIED_TO_READ: - weprintf("%s - No read access", file->filename); - break; - case IMLIB_LOAD_ERROR_UNKNOWN: - case IMLIB_LOAD_ERROR_NO_LOADER_FOR_FILE_FORMAT: - weprintf("%s - No Imlib2 loader for that file format", file->filename); - break; - case IMLIB_LOAD_ERROR_PATH_TOO_LONG: - weprintf("%s - Path specified is too long", file->filename); - break; - case IMLIB_LOAD_ERROR_PATH_COMPONENT_NON_EXISTANT: - weprintf("%s - Path component does not exist", file->filename); - break; - case IMLIB_LOAD_ERROR_PATH_COMPONENT_NOT_DIRECTORY: - weprintf("%s - Path component is not a directory", file->filename); - break; - case IMLIB_LOAD_ERROR_PATH_POINTS_OUTSIDE_ADDRESS_SPACE: - weprintf("%s - Path points outside address space", file->filename); - break; - case IMLIB_LOAD_ERROR_TOO_MANY_SYMBOLIC_LINKS: - weprintf("%s - Too many levels of symbolic links", file->filename); - break; - case IMLIB_LOAD_ERROR_OUT_OF_MEMORY: - weprintf("While loading %s - Out of memory", file->filename); - break; - case IMLIB_LOAD_ERROR_PERMISSION_DENIED_TO_WRITE: - weprintf("%s - Cannot write to directory", file->filename); - break; - case IMLIB_LOAD_ERROR_OUT_OF_DISK_SPACE: - weprintf("%s - Cannot write - out of disk space", file->filename); - break; - default: - weprintf("While loading %s - Unknown error (%d)", - file->filename, err); - break; - } - } + feh_imlib_print_load_error(file->filename, NULL, err) D(("Load *failed*\n")); return(0); } @@ -1024,7 +1029,8 @@ void feh_edit_inplace(winwidget w, int op) FEH_FILE(w->file->data)->filename, &err); gib_imlib_free_image(old); if (err) - im_weprintf(w, "Failed to save image after operation"); + feh_imlib_print_load_error(FEH_FILE(w->file->data)->filename, + w, err); feh_reload_image(w, 1, 1); } else { im_weprintf(w, "failed to load image from disk to edit it in place"); diff --git a/src/index.c b/src/index.c index e5a93a4..5d4ed39 100644 --- a/src/index.c +++ b/src/index.c @@ -329,7 +329,7 @@ void init_index_mode(void) ungib_imlib_save_image_with_error_return(im_main, output_buf, &err); if (err) { - weprintf("Cannot save image to %s", output_buf); + feh_imlib_print_load_error(output_buf, im_main, err); } else if (opt.verbose) { int tw, th; diff --git a/src/slideshow.c b/src/slideshow.c index 2e9c417..60bd99c 100644 --- a/src/slideshow.c +++ b/src/slideshow.c @@ -597,7 +597,7 @@ void slideshow_save_image(winwidget win) ungib_imlib_save_image_with_error_return(win->im, tmpname, &err); if (err) - im_weprintf(win, "Can't save image %s:", tmpname); + feh_imlib_print_load_error(tmpname, win, err); free(tmpname); return; diff --git a/src/thumbnail.c b/src/thumbnail.c index c622b07..fbe2ce0 100644 --- a/src/thumbnail.c +++ b/src/thumbnail.c @@ -384,7 +384,7 @@ void init_thumbnail_mode(void) strncpy(output_buf, opt.output_file, 1024); ungib_imlib_save_image_with_error_return(td.im_main, output_buf, &err); if (err) { - weprintf("Cannot save image to %s", output_buf); + feh_imlib_print_load_error(output_buf, td.im_main, err); } else if (opt.verbose) { int tw, th; -- cgit v1.2.3