diff --git a/man/feh.pre b/man/feh.pre index cdfaa155..2044c4a7 100644 --- a/man/feh.pre +++ b/man/feh.pre @@ -173,6 +173,9 @@ digital cameras and similar. If the ImageMagick convert binary is available, .Nm will use it to load file types such as svg, xcf, and otf. +Additionally +.Cm --force-conversion +can be used to skip the regular imlib2 image loading before trying to convert. . .Pp . @@ -339,6 +342,15 @@ zero causes to try indefinitely. Negative values restore the default by disabling conversion altogether. . +.It Cm --force-conversion +. +Force image conversion and skip the regular imlib2 image loading. +If +.Cm --conversion-timeout +is not set or negative, +.Cm --conversion-timeout +will be set to zero. +. .It Cm --class Ar class . Set the X11 class hint to diff --git a/src/help.raw b/src/help.raw index 0e99c689..bf8a425e 100644 --- a/src/help.raw +++ b/src/help.raw @@ -98,6 +98,9 @@ OPTIONS -Y, --hide-pointer Hide the pointer --conversion-timeout INT Load unknown files with dcraw or ImageMagick, timeout after INT seconds (0: no timeout) + --force-conversion Force image conversion and skip the regular imlib2 + image loading. Use conversion timeout of 0 if + timeout is not set or negative. --min-dimension WxH Only show images with width >= W and height >= H --max-dimension WxH Only show images with width <= W and height <= H --scroll-step COUNT scroll COUNT pixels when movement key is pressed diff --git a/src/imlib.c b/src/imlib.c index eb3f5224..20e4bc4a 100644 --- a/src/imlib.c +++ b/src/imlib.c @@ -336,6 +336,11 @@ int feh_load_image(Imlib_Image * im, feh_file * file) D(("filename is %s, image is %p\n", file->filename, im)); + if (opt.force_conversion && opt.conversion_timeout < 0) { + D(("Conversion forced without conversion timeout! Setting timeout to zero (infinite).\n")); + opt.conversion_timeout = 0; + } + if (!file || !file->filename) return 0; @@ -348,7 +353,11 @@ int feh_load_image(Imlib_Image * im, feh_file * file) } } else { - if (feh_is_image(file, 0)) { + if (opt.force_conversion) { + /* Use unknown error for later processing of converted image */ + err = IMLIB_LOAD_ERROR_UNKNOWN; + } + else if (feh_is_image(file, 0)) { *im = imlib_load_image_with_error_return(file->filename, &err); } else { feh_err = LOAD_ERROR_MAGICBYTES; @@ -360,12 +369,14 @@ int feh_load_image(Imlib_Image * im, feh_file * file) (err == IMLIB_LOAD_ERROR_UNKNOWN) || (err == IMLIB_LOAD_ERROR_NO_LOADER_FOR_FILE_FORMAT))) { if (feh_file_is_raw(file->filename)) { + D(("Trying image conversion with dcraw.\n")); image_source = SRC_DCRAW; tmpname = feh_dcraw_load_image(file->filename); if (!tmpname) { feh_err = LOAD_ERROR_DCRAW; } } else { + D(("Trying image conversion with imagemagick.\n")); image_source = SRC_MAGICK; feh_err = LOAD_ERROR_IMLIB; tmpname = feh_magick_load_image(file->filename); diff --git a/src/options.c b/src/options.c index 3f405faa..3bbd7b31 100644 --- a/src/options.c +++ b/src/options.c @@ -430,6 +430,7 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun) {"cache-size" , 1, 0, OPTION_cache_size}, {"on-last-slide" , 1, 0, OPTION_on_last_slide}, {"conversion-timeout" , 1, 0, OPTION_conversion_timeout}, + {"force-conversion" , 0, 0, OPTION_force_conversion}, {"version-sort" , 0, 0, OPTION_version_sort}, {"offset" , 1, 0, OPTION_offset}, #ifdef HAVE_INOTIFY @@ -830,6 +831,9 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun) case OPTION_conversion_timeout: opt.conversion_timeout = atoi(optarg); break; + case OPTION_force_conversion: + opt.force_conversion = 1; + break; case OPTION_version_sort: opt.version_sort = 1; break; diff --git a/src/options.h b/src/options.h index 2aed6a61..0ef814ce 100644 --- a/src/options.h +++ b/src/options.h @@ -148,6 +148,7 @@ struct __fehoptions { double slideshow_delay; signed int conversion_timeout; + int force_conversion; Imlib_Font menu_fn; }; @@ -250,6 +251,7 @@ OPTION_no_recursive, OPTION_cache_size, OPTION_on_last_slide, OPTION_conversion_timeout, +OPTION_force_conversion, OPTION_version_sort, OPTION_offset, OPTION_auto_reload,