Comments (14)
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.
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.
@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.
@DeniDoman, thanks for the wait! I believe version 3.0.1 should now fix the issue 🙌
Thanks for reporting the bug.
from jsquash.
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.
(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.
@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.
Thank you for the fix, @jamsinclair ! And huge thank you for the project overall, you rock!
from jsquash.
@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:
from jsquash.
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.
I'll see if I can improve the error messaging 🤔
from jsquash.
@jamsinclair thanks so much! I never thought about the extension. 😭
from jsquash.
@MeFelixWang No worries, easy mistake. Happens to all of us! Best of luck with your project.
from jsquash.
@jamsinclair Cheers for all the mistakes we made before! 😆
from jsquash.
Related Issues (20)
- Oxipng multi-threaded mode fails when run from main thread.
- Export single thread only methods for codecs that have multi-threading. HOT 1
- Doesn't work in Vite SSR HOT 5
- Simple CDN example HOT 5
- Cannot find module in sveltekit project HOT 6
- Issues with multi-threaded worker modules and Vite HOT 13
- Basic Node.js Support HOT 1
- Provide way to override WASM file location HOT 2
- Deno fails with "NotSupported: Classic workers are not supported." HOT 1
- Improve @jquash/avif decode speed HOT 6
- Create a reference decode speed benchmark page HOT 1
- Module not found HOT 1
- gif support? HOT 1
- Add type declarations for all wasm files? HOT 5
- jpeg and webp fail to import inside web worker HOT 2
- Resize component memory leak HOT 7
- Nuxt build error: UMD and IIFE output formats are not supported for code-splitting builds. HOT 4
- Passing a custom fetch function
- background execution? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jsquash.