cgohlke / imagecodecs

Image transformation, compression, and decompression codecs
https://pypi.org/project/imagecodecs
BSD 3-Clause "New" or "Revised" License
111 stars 21 forks source link

JPEG XL decoding problem: "RuntimeError: no frames found" #40

Closed axisfold closed 2 years ago

axisfold commented 2 years ago

When attempting to decode a specific JPEG XL file created using the libjxl binaries, RuntimeError: no frames found was thrown.

import imagecodecs

fname = "jxl_q10.jxl"
with open(fname, 'rb') as fh:
    jxlbytes = fh.read()
nparr = imagecodecs.jpegxl_decode(jxlbytes)

The libjxl decoder and imagemagick can decode it just fine, with djxl.exe .\jxl_q10.jxl out.png or magick convert .\jxl_q10.jxl out.png.

Code and sample file in this repository.

cgohlke commented 2 years ago

Something goes wrong in libjxl trying to count the number of frames in the file. You can get around that by specifying to read only the first frame: imagecodecs.jpegxl_decode(jxlbytes, index=0).