derf / feh

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

RAW images (.arw) fail to load with error message referencing TIFF #733

Closed Eisfunke closed 10 months ago

Eisfunke commented 10 months ago

I have RAW images from my camera (Sony Alpha 6000) with the extension .arw. I attached an example file with a random photo I had flying around on my PC. It shows some beautiful Dutch Gouda cheese :cheese:.

test.zip test.tar.gz

When I try to open it with feh I get the following output:

TIFFReadDirectory: Warning, Unknown field with tag 50341 (0xc4a5) encountered.
MissingRequired: TIFF directory is missing required "ImageLength" field.
feh WARNING: test.arw - No Imlib2 loader for that file format
feh: No loadable images specified.
See 'man feh' for detailed usage information

This happens even though I have both ImageMagick and dcraw installed which both correctly recognize the file:

$> identify test.arw
test.arw ARW 6024x4024 6048x4024+0+0 16-bit sRGB 23.7188MiB 0.000u 0:00.001

$> dcraw -i test.arw
test.arw is a Sony ILCE-6000 image.

And can also correctly convert it:

$> convert test.arw test.png
$> feh test.png
(works)

$> dcraw test.arw
$> feh test.ppm
(also works)

My guess is that feh incorrectly recognizes the file as TIFF image, because the file command also does:

$> file test.arw
test.arw: TIFF image data, little-endian, direntries=18, compression=JPEG (old), description=                               , manufacturer=SONY, model=ILCE-6000, orientation=upper-left, xresolution=278, yresolution=286, resolutionunit=2, software=ILCE-6000 v3.20, datetime=2023:01:22 11:20:24

The very small resolution and JPEG compression referenced in this output makes me think this has something to do with an embedded thumbnail? Not sure though. I tried changing around the file extension to various formats trying to fool file and maybe feh as well into not being fooled, but to no avail.

Anyaway, when I force ImageMagick to open the file as TIFF I get exactly the same error to the one feh gives me:

$> convert TIF:test.arw test.png
convert: Unknown field with tag 50341 (0xc4a5) encountered. `TIFFReadDirectory' @ warning/tiff.c/TIFFWarnings/958.
convert: TIFF directory is missing required "ImageLength" field. `MissingRequired' @ error/tiff.c/TIFFErrors/599.
convert: no images defined `test.png' @ error/convert.c/ConvertImageCommand/3359.

This is what leads me to my conclusion that feh recognizes the image as TIFF incorrectly, failing to open it as such, instead of passing it on to ImageMagick / directly to dcraw. I haven't taken a look into the code though.

Output of feh --version:

$> feh --version
feh version 
Compile-time switches: curl exif inotify verscmp xinerama 

Yeah, I guess nixpkgs broke the version output somehow. It's the current version from nixpkgs-unstable though, which is 3.10.1.

derf commented 10 months ago

feh only supports raw images (via dcraw) and other non-Imlib2 formats (via imagemagick) when called with --conversion-timeout N for some non-negative value N. It looks like your commandline is missing that; at least it works for me when specifying it while I get the same error as you do when leaving it out.

I'll adjust the documentation to mention the need for --conversion-timeout before listing support for dcraw and ImageMagick to decrease the chance of such misunderstandings.

Eisfunke commented 10 months ago

Oops. With --conversion-timeout it works for me as well. It seems when reading the relevant manual section my brain automatically reduced "Use --conversion-timeout timeout with a non-negative value to enable support for these formats." to "use --conversion-timeout to adjust the timeout" without understanding that it's also needed to turn conversion on at all and assumed I would only need that if I wanted to change a default timeout value. My fault. Thank you very much for the quick reply!