rlepigre / ocaml-imagelib

The imagelib library implements image formats such as PNG or PPM
GNU Lesser General Public License v3.0
39 stars 13 forks source link

Multiple valid PNG images raise Corrupted_image exception on reading #51

Closed iitalics closed 3 years ago

iitalics commented 3 years ago

Hello. I'm interested in using this library for some simple loading PNG images into memory. However I'm encountering a lot of Currpoted_image exceptions on images that seem perfectly valid to other image readers. I really am not an expert on the PNG file format so I can't say much of why these images might not be working but it's coming as a surprise to me that I get zlib failures for various innocuous files on my computer.

Here are three such images that do not work:

(sorry for the weird images, I was just picking random ones from my downloads folder)

iitalics commented 3 years ago

The invocation I'm using to read is ImageLib_unix.openfile "<filename>.png", and I just installed this library after a recent OPAM update so I should have new versions:

$ opam install imagelib
The following actions will be performed:
  - install optint     0.1.0    [required by decompress]
  - install checkseum  0.3.1    [required by decompress]
  - install decompress 1.4.0    [required by imagelib]
  - install imagelib   20210402
mseri commented 3 years ago

Does it work if you do opam install decompress.1.3.0? I think the latest decompress released yesterday may have introduced some breaking changes

eWert-Online commented 3 years ago

I am getting the same error (PNG.Zlib:Invalid complement of length) on my images. Downgrading decompress to 1.3.0 did not help.

Here is the debug log of my error:

Open ``` IHDR content: - image size: 1920x4699 - bit depth: 8 - colour type: 6 - compression_method: 0 - filter_method: 0 - interlace_method: 0 IDAT (raw data is now 8192 bytes long) IDAT (raw data is now 16384 bytes long) IDAT (raw data is now 24576 bytes long) IDAT (raw data is now 32768 bytes long) IDAT (raw data is now 40960 bytes long) IDAT (raw data is now 49152 bytes long) IDAT (raw data is now 57344 bytes long) IDAT (raw data is now 65536 bytes long) IDAT (raw data is now 73728 bytes long) IDAT (raw data is now 81920 bytes long) IDAT (raw data is now 90112 bytes long) IDAT (raw data is now 98304 bytes long) IDAT (raw data is now 106496 bytes long) IDAT (raw data is now 114688 bytes long) IDAT (raw data is now 122880 bytes long) IDAT (raw data is now 131072 bytes long) IDAT (raw data is now 139264 bytes long) IDAT (raw data is now 147456 bytes long) IDAT (raw data is now 155648 bytes long) IDAT (raw data is now 163840 bytes long) IDAT (raw data is now 172032 bytes long) IDAT (raw data is now 180224 bytes long) IDAT (raw data is now 188416 bytes long) IDAT (raw data is now 196608 bytes long) IDAT (raw data is now 204800 bytes long) IDAT (raw data is now 212992 bytes long) IDAT (raw data is now 221184 bytes long) IDAT (raw data is now 229376 bytes long) IDAT (raw data is now 237568 bytes long) IDAT (raw data is now 245760 bytes long) IDAT (raw data is now 253952 bytes long) IDAT (raw data is now 262144 bytes long) IDAT (raw data is now 270336 bytes long) IDAT (raw data is now 278528 bytes long) IDAT (raw data is now 286720 bytes long) IDAT (raw data is now 294912 bytes long) IDAT (raw data is now 303104 bytes long) IDAT (raw data is now 311296 bytes long) IDAT (raw data is now 319488 bytes long) IDAT (raw data is now 327680 bytes long) IDAT (raw data is now 335872 bytes long) IDAT (raw data is now 344064 bytes long) IDAT (raw data is now 352256 bytes long) IDAT (raw data is now 360448 bytes long) IDAT (raw data is now 368640 bytes long) IDAT (raw data is now 376832 bytes long) IDAT (raw data is now 385024 bytes long) IDAT (raw data is now 393216 bytes long) IDAT (raw data is now 401408 bytes long) IDAT (raw data is now 409600 bytes long) IDAT (raw data is now 417792 bytes long) IDAT (raw data is now 425984 bytes long) IDAT (raw data is now 434176 bytes long) IDAT (raw data is now 442368 bytes long) IDAT (raw data is now 450560 bytes long) IDAT (raw data is now 458752 bytes long) IDAT (raw data is now 466944 bytes long) IDAT (raw data is now 475136 bytes long) IDAT (raw data is now 483328 bytes long) IDAT (raw data is now 491520 bytes long) IDAT (raw data is now 499712 bytes long) IDAT (raw data is now 507904 bytes long) IDAT (raw data is now 516096 bytes long) IDAT (raw data is now 524288 bytes long) IDAT (raw data is now 532480 bytes long) IDAT (raw data is now 540672 bytes long) IDAT (raw data is now 548864 bytes long) IDAT (raw data is now 557056 bytes long) IDAT (raw data is now 565248 bytes long) IDAT (raw data is now 573440 bytes long) IDAT (raw data is now 581632 bytes long) IDAT (raw data is now 589824 bytes long) IDAT (raw data is now 598016 bytes long) IDAT (raw data is now 606208 bytes long) IDAT (raw data is now 614400 bytes long) IDAT (raw data is now 622592 bytes long) IDAT (raw data is now 630784 bytes long) IDAT (raw data is now 638976 bytes long) IDAT (raw data is now 647168 bytes long) IDAT (raw data is now 655360 bytes long) IDAT (raw data is now 663552 bytes long) IDAT (raw data is now 671744 bytes long) IDAT (raw data is now 679936 bytes long) IDAT (raw data is now 688128 bytes long) IDAT (raw data is now 696320 bytes long) IDAT (raw data is now 704512 bytes long) IDAT (raw data is now 712704 bytes long) IDAT (raw data is now 720896 bytes long) IDAT (raw data is now 729088 bytes long) IDAT (raw data is now 737280 bytes long) IDAT (raw data is now 745472 bytes long) IDAT (raw data is now 753664 bytes long) IDAT (raw data is now 761856 bytes long) IDAT (raw data is now 770048 bytes long) IDAT (raw data is now 778240 bytes long) IDAT (raw data is now 786432 bytes long) IDAT (raw data is now 794624 bytes long) IDAT (raw data is now 802816 bytes long) IDAT (raw data is now 811008 bytes long) IDAT (raw data is now 819200 bytes long) IDAT (raw data is now 827392 bytes long) IDAT (raw data is now 835584 bytes long) IDAT (raw data is now 843776 bytes long) IDAT (raw data is now 851968 bytes long) IDAT (raw data is now 860160 bytes long) IDAT (raw data is now 866132 bytes long) IEND reached internal error, uncaught exception: Image.Corrupted_image("PNG.Zlib:Invalid complement of length") Raised at ImagePNG.PNG_Zlib.uncompress_string in file "src/imagePNG.ml", line 80, characters 26-69 Called from ImagePNG.ReadPNG.parsefile in file "src/imagePNG.ml", line 865, characters 22-49 Called from ImageLib_unix.openfile in file "unix/imageLib_unix.ml", line 58, characters 6-38 ... ```
hannesm commented 3 years ago

//cc @dinosaure @clecat who may be interested in zlib/decompress issues

dinosaure commented 3 years ago

Hi, thanks I will try to find times to find where is the bug :+1:.

dinosaure commented 3 years ago

After a try, it seems that the error is about how we use decompress instead of decompress itself which is a good news :+1: - that mostly means that a release of it is not really needed.

dinosaure commented 3 years ago

Really sorry for the disturb... I inserted a bug on the implementation of imagelib. I proposed a simple fix on #52 and all of your images should be fine :tada:.

mseri commented 3 years ago

@rlepigre should I make the release or you plan to do it?

rlepigre commented 3 years ago

You can go ahead and do it if you want @mseri. (I would probably mess it up since I have not made one in a while.)

mseri commented 3 years ago

👍 done