{"_id":"@cantoo/upng","name":"@cantoo/upng","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@cantoo/upng","version":"1.0.0","description":"Small, fast and advanced PNG / APNG encoder and decoder (vendored for @cantoo/pdf-lib)","main":"./dist/index.cjs","module":"./dist/index.mjs","types":"./dist/index.d.ts","unpkg":"./dist/index.umd.js","jsdelivr":"./dist/index.umd.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.cjs"},"./package.json":"./package.json"},"scripts":{"build":"node ../../../scripts/build-packages.mjs","prepack":"npm run build"},"dependencies":{"fflate":"^0.8.2"},"repository":{"type":"git","url":"git://github.com/cantoo-scribe/pdf-lib.git","directory":"src/packages/upng"},"author":{"name":"photopea","url":"https://github.com/photopea"},"contributors":[{"name":"Andrew Dillon","url":"https://github.com/Hopding"},{"name":"Cantoo"},{"name":"Scimonster","url":"https://github.com/Scimonster"}],"license":"MIT","publishConfig":{"access":"public"},"keywords":["png","apng","image","conversion"],"_id":"@cantoo/upng@1.0.0","gitHead":"eafae49f9704b037b9474bd51309c3e9dca0e44b","bugs":{"url":"https://github.com/cantoo-scribe/pdf-lib/issues"},"homepage":"https://github.com/cantoo-scribe/pdf-lib#readme","_nodeVersion":"22.23.2","_npmVersion":"10.9.8","dist":{"integrity":"sha512-Z7Sg8ncfp3xI7zC+wpBvjYo+T2x1hgUtoGhj/o8hgsYFIckAn7yTMZhONZEcI5jvYW9FqMy39D56LsT0YQcAnw==","shasum":"128f3b10fc4ba50146904c73245a86b75b98e0d1","tarball":"https://registry.npmjs.org/@cantoo/upng/-/upng-1.0.0.tgz","fileCount":29,"unpackedSize":628153,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIHseMSylLrjCHYu0HWL0sxfBBjhpbD1yUgICAzesHBD4AiAWtgsmw4QjZjy8QJ53Ip0OLRKf0nprlLCOq44g89sNhw=="}]},"_npmUser":{"name":"sharcoux","email":"f.billioud@gmail.com"},"directories":{},"maintainers":[{"name":"sharcoux","email":"f.billioud@gmail.com"},{"name":"ribeirofmatheus","email":"matheus_f.ribeiro@hotmail.com"},{"name":"matheusrdsantos","email":"matheus.r.d.s10@hotmail.com"},{"name":"gabrielnsd","email":"gabrielnsdantas@gmail.com"},{"name":"felipecantoo","email":"felipe@cantoo.fr"},{"name":"nicodemos234","email":"nicodemos54324@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/upng_1.0.0_1789094716368_0.004041959591286837"},"_hasShrinkwrap":false}},"time":{"created":"2026-09-11T02:45:16.199Z","1.0.0":"2026-09-11T02:45:16.522Z","modified":"2026-09-11T02:45:16.823Z"},"maintainers":[{"name":"sharcoux","email":"f.billioud@gmail.com"},{"name":"ribeirofmatheus","email":"matheus_f.ribeiro@hotmail.com"},{"name":"matheusrdsantos","email":"matheus.r.d.s10@hotmail.com"},{"name":"gabrielnsd","email":"gabrielnsdantas@gmail.com"},{"name":"felipecantoo","email":"felipe@cantoo.fr"},{"name":"nicodemos234","email":"nicodemos54324@gmail.com"}],"description":"Small, fast and advanced PNG / APNG encoder and decoder (vendored for @cantoo/pdf-lib)","homepage":"https://github.com/cantoo-scribe/pdf-lib#readme","keywords":["png","apng","image","conversion"],"repository":{"type":"git","url":"git://github.com/cantoo-scribe/pdf-lib.git","directory":"src/packages/upng"},"contributors":[{"name":"Andrew Dillon","url":"https://github.com/Hopding"},{"name":"Cantoo"},{"name":"Scimonster","url":"https://github.com/Scimonster"}],"author":{"name":"photopea","url":"https://github.com/photopea"},"bugs":{"url":"https://github.com/cantoo-scribe/pdf-lib/issues"},"license":"MIT","readme":"# @cantoo/upng\n\nPNG / APNG encoder and decoder based on [photopea/UPNG.js](https://github.com/photopea/UPNG.js) via [`@pdf-lib/upng`](https://github.com/Hopding/upng) (the library Hopding wired into pdf-lib in [PR #361](https://github.com/Hopding/pdf-lib/pull/361)), vendored for [`@cantoo/pdf-lib`](https://github.com/cantoo-scribe/pdf-lib).\n\n## Benefits vs original UPNG / `@pdf-lib/upng`\n\n|             | photopea/UPNG.js & `@pdf-lib/upng`              | `@cantoo/upng`                                                                  |\n| ----------- | ----------------------------------------------- | ------------------------------------------------------------------------------- |\n| Compression | `pako`                                          | **[`fflate`](https://www.npmjs.com/package/fflate)**                            |\n| Packaging   | Separate npm package                            | Also shipped as `@cantoo/pdf-lib/upng`                                          |\n| Source      | One monolithic `UPNG.js`                        | **Modular TypeScript** (`decode`, `encode`, `quantize`, `framize`, `filter`, …) |\n| Encode      | Full UPNG (`quantize`, `framize`, lossy `cnum`) | **Same** feature set, ported from photopea's current sources                    |\n| Types       | `@pdf-lib/upng` ships `.d.ts`                   | Same public surface, types generated from the sources                           |\n\nThe encoder keeps photopea's KD-tree + k-means quantization, APNG `framize`, and lossy palette encode when `cnum` &lt; number of colors.\n\n## API\n\n```ts\nimport UPNG from '@cantoo/upng';\n\nconst img = UPNG.decode(/* ArrayBuffer */);\nconst rgba = UPNG.toRGBA8(img)[0]; // ArrayBuffer of RGBA8 pixels\n\nconst png = UPNG.encode([rgba], width, height, 0); // 0 = lossless / auto\nconst pngQ = UPNG.encode([rgba], width, height, 256); // quantize to ≤256 colors\nconst q = UPNG.quantize(rgba, 64);\nconst pngLL = UPNG.encodeLL([samples], width, height, 3, 1, 8);\n```\n\n`UPNG.compress` (also a named export) gives finer control over framing,\npalette and dithering:\n\n```ts\n// [onlyBlend, evenCrd, forbidPrev, minBits, forbidPlte, dither]\nconst nimg = UPNG.compress([rgba], width, height, 64, [\n  false,\n  false,\n  false,\n  0,\n  false,\n  true,\n]);\n```\n\nAlso available via `@cantoo/pdf-lib/upng` when pdf-lib is installed.\n","readmeFilename":"README.md","_rev":"1-df4d4f53217cdcdb53011e4db8eb1c88"}