Giter Club home page Giter Club logo

Comments (14)

jamsinclair avatar jamsinclair commented on July 27, 2024 2

Thanks for the report @DeniDoman. Not sure how this worked before... there now seems to be a bug with how we handle non-RGBA PNG files.

I'll have a fix ready shortly.

from jsquash.

jamsinclair avatar jamsinclair commented on July 27, 2024 1

So the PNG itself is technically corrupted. It has an invalid ICC PROFILE checksum (Also reported by the tool https://www.nayuki.io/page/png-file-chunk-inspector). However, most systems seem to ignore this and still render the image.

The rust error is:

CRC error: expected 0x768af32e have 0x723989cd while decoding ChunkType { type: iCCP, critical: false, private: false, reserved: false, safecopy: false } chunk.

I'll need to make some time to comeback to this and see how to ignore this checksum check. In the interim, you could try use an image editor to resave the PNG correctly.

from jsquash.

jamsinclair avatar jamsinclair commented on July 27, 2024 1

@CodeF53 I've released @jsquash/[email protected] which should now work with your broken pngs 👌

As it was going to require a major version release, I also included some other breaking changes. Please see the PR (#45) or Changelog file for details 🙇 .

Hope this helps with your app, happy new year! 🎉

from jsquash.

jamsinclair avatar jamsinclair commented on July 27, 2024 1

@DeniDoman, thanks for the wait! I believe version 3.0.1 should now fix the issue 🙌

Thanks for reporting the bug.

from jsquash.

jamsinclair avatar jamsinclair commented on July 27, 2024

Thanks for the report @CodeF53. After playing around it seems like there might be an issue with the PNG decoding codec. Squoosh's implementation was quite basic and just repurposed the rust lib/png library.

When I find some time I'll see if I can find the exact error that is being reported in Rust and see if that helps us narrow it down. Alternatively, if you're running this code in the browser, you can likely utilize the Canvas API in the interim for a lightweight and faster png decoder to get the imagedata (See MDN docs).

from jsquash.

CodeF53 avatar CodeF53 commented on July 27, 2024

(Repost because github mobile app showed I sent it twice. So I tried deleting the duplicate, only to have both comments dissappear. Thanks github mobile!)

I kind of expected it would be something like that, but thought it shouldn't matter because so many other applications don't seem to care.

I implemented a canvas based encode/decode fallback into my app for when this error occurs, but it is 10x slower than this library.

And that sucks because my app is used by people who aren't the person who made the images they are processing. So they have no clue their images could be improperly encoded. So my app just looks buggy/slow to them.

from jsquash.

DeniDoman avatar DeniDoman commented on July 27, 2024

@jamsinclair could you please double check your fix? Because in the same example: Reproduction - broken.png decoding is fixed, but working.png decoding now fails with the following error:

error: Uncaught (in promise) IndexSizeError: Failed to construct 'ImageData': The input data length is not equal to (4 * width * height).

from jsquash.

DeniDoman avatar DeniDoman commented on July 27, 2024

Thank you for the fix, @jamsinclair ! And huge thank you for the project overall, you rock!

from jsquash.

MeFelixWang avatar MeFelixWang commented on July 27, 2024

@jamsinclair thanks for this great project! I'm using "@jsquash/png": "^3.0.1", but Error: 'unwrap_throw' failed still exists, any updates?

Here is the png file:

king-vulture-8350517_640

from jsquash.

jamsinclair avatar jamsinclair commented on July 27, 2024

Thanks @MeFelixWang, that appears to be because the file is actually a jpeg and not a png. It has been given the wrong file extension.

Reading the file with the UNIX file command returns:

JPEG image data, JFIF standard 1.01, aspect ratio, density 1x1, segment length 16, progressive, precision 8, 640x451, components 3

from jsquash.

jamsinclair avatar jamsinclair commented on July 27, 2024

I'll see if I can improve the error messaging 🤔

from jsquash.

MeFelixWang avatar MeFelixWang commented on July 27, 2024

@jamsinclair thanks so much! I never thought about the extension. 😭

from jsquash.

jamsinclair avatar jamsinclair commented on July 27, 2024

@MeFelixWang No worries, easy mistake. Happens to all of us! Best of luck with your project.

from jsquash.

MeFelixWang avatar MeFelixWang commented on July 27, 2024

@jamsinclair Cheers for all the mistakes we made before! 😆

from jsquash.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.