derf / feh

a fast and light image viewer
https://feh.finalrewind.org
Other
1.51k stars 159 forks source link

Fails to open images with width or height >= 32767 #247

Open amaurea opened 8 years ago

amaurea commented 8 years ago

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.

absudabsu commented 7 years ago

Same issue in 2017, fedora 25.

Ferada commented 4 years ago

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.

0xmatthias commented 3 years ago

Best way is probably to update feh's manpage about this limitation.