feh
feh copied to clipboard
Fails to open images with width or height >= 32767
How to reproduce:
$ convert -size 32768x100 xc:red test.png
$ feh test.png
Expected behavior: Feh displays a uniformly red image. Actual result: A corrupted window with white garbage on a black background. Error messages from the relevant image library are displayed in the terminal. For example, for png images, I see the following:
libpng warning: IDAT: bad parameters to zlib libpng error: [00][00][00][25]: invalid chunk type libpng warning: IDAT: bad parameters to zlib libpng error: [00][00][00][25]: invalid chunk type
Scrolling the image replaces the garbage with uniform white while producing more error messages.
While the error messages make it seem like a problem with e.g. libpng, very similar things happen with all the other image formats I've tried. For example:
$ convert -size 32768x0 xc:red test.jpg
$ feh test.jpg
results in the error message
feh WARNING: test.jpg - No Imlib2 loader for that file format feh: No loadable images specified. See 'feh --help' or 'man feh' for detailed usage information
In this case feh doesn't even open a window to display the file. The same thing happens with gif.
I think this is a regression in feh - I think I could open images like this a year ago.
Same issue in 2017, fedora 25.
Checked with current feh and Imlib2, the files definitely don't load, but also show no corruption?
As for the reason (imlib2/src/lib/image.h
):
/* 32767 is the maximum pixmap dimension and ensures that
* (w * h * sizeof(DATA32)) won't exceed ULONG_MAX */
#define X_MAX_DIM 32767
/* NB! The image dimensions are sometimes used in (dim << 16) like expressions
* so great care must be taken if ever it is attempted to change this
* condition */
#define IMAGE_DIMENSIONS_OK(w, h) \
( ((w) > 0) && ((h) > 0) && ((w) <= X_MAX_DIM) && ((h) <= X_MAX_DIM) )
That'd be a quite an involved change in Imlib2 to adjust these limits.
Since the library simply refuses to load the images, perhaps at least the error code could indicate that the file exceeded supported dimensions. Again would require some more changes in Imlib2.
Best way is probably to update feh's manpage about this limitation.