{"id":28642088,"url":"https://github.com/jamsinclair/jSquash","last_synced_at":"2025-06-12T22:03:23.775Z","repository":{"id":37926741,"uuid":"426283066","full_name":"jamsinclair/jSquash","owner":"jamsinclair","description":"Browser \u0026 Web Worker focussed image codec wasm bundles derived from the Squoosh App.","archived":false,"fork":false,"pushed_at":"2025-05-22T02:28:15.000Z","size":22261,"stargazers_count":438,"open_issues_count":15,"forks_count":22,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-05-28T20:07:32.226Z","etag":null,"topics":["avif","image","image-codec","image-codecs","image-decoder","image-encoder","image-processing","jpegxl","png","wasm","web-assembly","webassembly"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jamsinclair.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-11-09T15:29:57.000Z","updated_at":"2025-05-23T05:40:53.000Z","dependencies_parsed_at":"2024-01-13T10:09:12.335Z","dependency_job_id":"5d9899c5-cbbc-426c-a94b-e1ad3ae94d37","html_url":"https://github.com/jamsinclair/jSquash","commit_stats":{"total_commits":228,"total_committers":6,"mean_commits":38.0,"dds":"0.13596491228070173","last_synced_commit":"ce5ffac7da07f14613f6673c8f15e490f7a862dc"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jamsinclair/jSquash","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamsinclair%2FjSquash","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamsinclair%2FjSquash/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamsinclair%2FjSquash/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamsinclair%2FjSquash/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jamsinclair","download_url":"https://codeload.github.com/jamsinclair/jSquash/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamsinclair%2FjSquash/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259539025,"owners_count":22873332,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["avif","image","image-codec","image-codecs","image-decoder","image-encoder","image-processing","jpegxl","png","wasm","web-assembly","webassembly"],"created_at":"2025-06-12T22:02:11.781Z","updated_at":"2025-06-12T22:03:23.766Z","avatar_url":"https://github.com/jamsinclair.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# jSquash 🥝\n\n\u003e Collection of WebAssembly image codecs that support the browser and are derived from the [Squoosh App](https://github.com/GoogleChromeLabs/squoosh)\n\nThe aim of this library is to provide an easy experience to encode, decode and modify images with the tools you know and love from Squoosh in the **Browser** and **Web Worker** environments.\n\njSquash name is inspired by jQuery and Squoosh. It symbolizes the browser support focus of these packages.\n\n⚠️ There is limited support for Node.js environments. The experimental Node.js support is provided for convenience and is not the primary focus of this project. For much better Node based alternatives please check out the [Squoosh Node.js library](https://github.com/GoogleChromeLabs/squoosh/tree/918c596cba36a46ff3d7aa8ffd69580bd22528e2/libsquoosh) and [Sharp](https://github.com/lovell/sharp).\n\n## Differences with Squoosh\n\n- The codecs and tools are built for both Web and Web Worker environments\n- No dynamic code execution, the packages can be run in strict environments that do not allow code evaluation. Like Cloudflare Workers.\n- Does not rely on TextEncoder/TextDecoder API (could reduce performance) but allows it to be run in simpler V8 runtimes that only support UTF-8 (Cloudflare Workers, Vercel Edge Functions etc.)\n\n## Packages\n\n- [@jSquash/avif](/packages/avif) - An encoder and decoder for AVIF images using the [libavif](https://github.com/AOMediaCodec/libavif) library\n- [@jSquash/jpeg](/packages/jpeg) - An encoder and decoder for JPEG images using the [MozJPEG](https://github.com/mozilla/mozjpeg) library\n- [@jSquash/jxl](/packages/jxl) - An encoder and decoder for JPEG XL images using the [libjxl](https://github.com/libjxl/libjxl) library\n- [@jSquash/oxipng](/packages/oxipng) - A PNG image optimiser using [Oxipng](https://github.com/shssoichiro/oxipng)\n- [@jSquash/png](/packages/png) - An encoder and decoder for PNG images using the [rust PNG crate](https://docs.rs/png/0.11.0/png/)\n- [@jSquash/qoi](/packages/qoi) - An encoder and decoder for the \"Quite Ok Image Format\" using the [official library](https://github.com/phoboslab/qoi)\n- [@jSquash/resize](/packages/resize) - An image resizer tool using rust [resize](https://github.com/PistonDevelopers/resize), [hqx](https://github.com/CryZe/wasmboy-rs/tree/master/hqx) and [magic-kernel](https://github.com/SevInf/magic-kernel-rust) libraries. Supports both downscaling and upscaling.\n- [@jSquash/webp](/packages/webp) - An encoder and decoder for WebP images using [libwebp](https://github.com/webmproject/libwebp)\n- ...more to come\n\n⚠️ All packages are ESM modules. You may need to manually transpile the packages if your build environment still relies on Commonjs formats.\n\n## Usage in the Browser\n\nYou can use the packages directly from the Unpkg CDN and can be the easiest way to get started.\n\n```js\nimport { decode } from \"https://unpkg.com/@jsquash/jpeg?module\";\nimport { encode } from \"https://unpkg.com/@jsquash/webp?module\";\n\nconst imageResponse = await fetch(\"https://picsum.photos/200/300.jpg\");\nconst imageData = await decode(await imageResponse.arrayBuffer());\nconst webpImageBuffer = await encode(imageData);\n```\n\nTo target a specific version, you can use the `@version` syntax.\n```js\nimport { encode } from \"https://unpkg.com/@jsquash/webp@1.2.0?module\";\n```\n\nCheckout the [with CDN](/examples/with-cdn) example for a working demo.\n\n## Usage in Node.js\n\nUsing jSquash modules with Node.js requires some additional steps so that the WASM binaries can be included.\nThe support is limited and the WASM modules are not optimized for speed with Node.js.\n\nCheck out the [with Node.js](/examples/with-node) example for a working demo.\n\n## Usage in Cloudflare Workers\n\nUsing jSquash modules with Cloudflare Workers requires some additional steps so that the WASM binaries get included.\n\nDepending on which format you are using check the examples below:\n- [Cloudflare Worker (ES Module Format) function that upgrades images to webp](/examples/cloudflare-worker-esm-format)\n- [Cloudflare Worker (Legacy Service Worker Format) function that upgrades images to webp](/examples/cloudflare-worker)\n\n## Other Examples\n\n- [Web App using image codecs bundled with Rollup](/examples/with-rollup)\n- [Web App using image codecs bundled with Vite](/examples/with-vite)\n- [Web App using image codecs bundled with Webpack](/examples/with-webpack)\n- [Deno script that converts images from the file system](/examples/with-deno)\n\n## Known Issues\n\n### Issues with Vite and Vue build environments\n\nThis may present itself as any of the following errors:\n- `TypeError: Failed to construct 'URL': Invalid URL`\n- `RuntimeError: Aborted(both async and sync fetching of the wasm failed). Build with -sASSERTIONS for more info.`\n- Other console errors could also be related to this issue\n\nAs a workaround, update your `vite.config.js` file with the `optimizeDeps` property. Put affected module names in the exclude array. Vites dependency optimizer seems to be causing issues with the WASM modules.\n\n```js\nimport { defineConfig } from 'vite'\n\nexport default defineConfig({\n  optimizeDeps: {\n    exclude: [\"@jsquash/png\"]\n  }\n})\n```\n\n### Issues with Nuxt build environments\n\nThis may present itself as a `Cannot find module` error. This is likely because Nuxt is anticipating third party modules to be in the Commonjs format.\n\nSetting the following Nuxt config with the jSquash packages that your app uses seems to resolve it.\n\n```js\nexport default defineNuxtConfig({\n  build: {\n    transpile: [\"@jsquash/png\"],\n  },\n  vite: {\n    optimizeDeps: {\n      exclude: [\"@jsquash/png\"],\n    },\n  },\n});\n```\n\n### Issues with Nuxt/Vite and nested Web Workers\n\nThere is a known Vite bug breaking production code compilation when using a worker that references another worker, see [issue #19](https://github.com/jamsinclair/jSquash/issues/19) for more information.\n\n```\nUnexpected early exit. This happens when Promises returned by plugins cannot resolve. Unfinished hook action(s) on exit:\n```\n\nIn the meantime, you can install special builds that don't use workers to work around this issue:\n- [@jsquash/avif@1.1.2-single-thread-only](https://www.npmjs.com/package/@jsquash/avif/v/1.1.2-single-thread-only)\n- [@jsquash/jxl@1.0.2-single-thread-only](https://www.npmjs.com/package/@jsquash/jxl/v/1.0.2-single-thread-only)\n- [@jsquash/oxipng@1.0.1-single-thread-only](https://www.npmjs.com/package/@jsquash/oxipng/v/1.0.1-single-thread-only)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjamsinclair%2FjSquash","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjamsinclair%2FjSquash","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjamsinclair%2FjSquash/lists"}