gchudnov / inkjet

JPEG-image decoding, encoding & EXIF reading library for a browser and node.js
MIT License
225 stars 6 forks source link

Crashes when decoding JPGs w/ sRGB IEC61966-2.1 color profile #5

Open bvandenbos opened 7 years ago

bvandenbos commented 7 years ago

At least the color profile seems to be the consistent factor. May also be true for other profiles. I can decode JPGs w/out a profile just fine.

Stack trace:

TypeError: Cannot read property '0' of undefined
    at quantizeAndInverse (jpg.js:448)
    at buildComponentData (jpg.js:586)
    at constructor.parse (jpg.js:820)
    at JpegImage.parse (jpg.js:68)

Example image: 3

gchudnov commented 7 years ago

got it, thank you for the bug report. I'll look into it.

dalisoft commented 4 years ago

Same issue here

gchudnov commented 4 years ago

@dalisoft do you have another example for an image?

dalisoft commented 4 years ago

16_out

I used PNG from here

Steps do this: If you have macOS, then you can do this by:

  1. Open any image with macOS built-in photo viewer
  2. Export image and select JPEG (select quality to High)

If you using Windows:

  1. Open any PNG image with Adobe Photoshop (you can use free trial if haven't purchased)
  2. After opening dialog will be be opened to select which color profile
  3. Select sRGB (... no matter specs number)
dexo568 commented 4 years ago

I also ran into this issue. This was an issue with the underlying jpgJS library: https://github.com/notmasteryet/jpgjs/issues/34 However, they seemed to have fixed it here: https://github.com/notmasteryet/jpgjs/pull/36 I solved the problem by just using the current version of jpgjs directly rather than Inkjet, but I suspect this library could be fixed by simply updating the jpg.js file to a more current version.

gchudnov commented 4 years ago

today started upgrading all underlying libraries, but might take some time..

gchudnov commented 4 years ago

preliminary fix is here: https://github.com/gchudnov/inkjet/pull/7 released as 3.0.0-rc0.

if used in node.js: require('inkjet').default should be used. will revert back to require('inkjet') in rc1.