{"_id":"@adnsistemas/upng","_rev":"4-4e843d0e3d01d4afbb6c3fb4d23e3d18","name":"@adnsistemas/upng","dist-tags":{"latest":"1.0.4"},"versions":{"1.0.1":{"name":"@adnsistemas/upng","version":"1.0.1","keywords":["png","apng","image","conversion"],"author":{"url":"https://github.com/photopea","name":"photopea"},"license":"MIT","_id":"@adnsistemas/upng@1.0.1","maintainers":[{"name":"adnsistemas","email":"dabdala@adnsistemas.com.ar"}],"contributors":[{"url":"https://github.com/Hopding","name":"Andrew Dillon"},{"url":"https://github.com/Scimonster","name":"Scimonster"},{"url":"https://github.com/thekonz","name":"Konstantin Duczek"},{"name":"David Abdala"}],"homepage":"https://github.com/adnsistemas/upng#readme","bugs":{"url":"https://github.com/adnsistemas/upng/issues"},"npm":{"publish":false},"dist":{"shasum":"8cd10efd90b0a50417e0f5cf4d12741b040f1ee7","tarball":"https://registry.npmjs.org/@adnsistemas/upng/-/upng-1.0.1.tgz","fileCount":8,"integrity":"sha512-JrY6fmgrIwsJtnP/EeZtV/epUPVi7ZtL8w42jCZY6a7eE0xNB3eca6OAZiU/jOEFXJDmN5mmg3V/RveEgMLh7w==","signatures":[{"sig":"MEQCIA9SAblN3VlNmVPjbG6EWMUp+9QIFkXQTbSWzGF1IANTAiB5eloxKk9guN9bkF8ZvgMkT+/ETzPilSZZd9zfmkY47A==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":659452},"main":"cjs/UPNG.js","types":"index.d.ts","unpkg":"dist/UPNG.min.js","module":"UPNG.js","gitHead":"8695ace28efc4de25b6c88cc393b6c52cb4f9606","private":false,"scripts":{"build":"yarn build:cjs && yarn build:umd && yarn build:umd:min","release":"release-it","build:cjs":"babel --plugins @babel/plugin-transform-modules-commonjs --out-dir cjs UPNG.js","build:umd":"rollup --config rollup.config.js --file dist/UPNG.js","build:umd:min":"rollup --config rollup.config.js --file dist/UPNG.min.js --environment MINIFY"},"_npmUser":{"name":"adnsistemas","email":"dabdala@adnsistemas.com.ar"},"repository":{"url":"git+https://github.com/adnsistemas/upng.git","type":"git"},"_npmVersion":"10.8.2","description":"Small, fast and advanced PNG / APNG encoder and decoder","directories":{},"_nodeVersion":"20.17.0","dependencies":{"pako":"^1.0.10"},"publishConfig":{"registry":"https://registry.npmjs.org"},"_hasShrinkwrap":false,"packageManager":"yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e","devDependencies":{"rollup":"^1.31.1","@babel/cli":"^7.8.4","release-it":"^17.0.3","@babel/core":"^7.8.4","rollup-plugin-terser":"^5.1.3","@rollup/plugin-commonjs":"^11.0.0","@rollup/plugin-node-resolve":"^7.1.1","@babel/plugin-transform-modules-commonjs":"^7.8.3"},"_npmOperationalInternal":{"tmp":"tmp/upng_1.0.1_1764718601098_0.0984519601715299","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@adnsistemas/upng","version":"1.0.2","keywords":["png","apng","image","conversion"],"author":{"url":"https://github.com/photopea","name":"photopea"},"license":"MIT","_id":"@adnsistemas/upng@1.0.2","maintainers":[{"name":"adnsistemas","email":"dabdala@adnsistemas.com.ar"}],"contributors":[{"url":"https://github.com/Hopding","name":"Andrew Dillon"},{"url":"https://github.com/Scimonster","name":"Scimonster"},{"url":"https://github.com/thekonz","name":"Konstantin Duczek"},{"name":"David Abdala"}],"homepage":"https://github.com/adnsistemas/upng#readme","bugs":{"url":"https://github.com/adnsistemas/upng/issues"},"npm":{"publish":false},"dist":{"shasum":"cdd6ad9eb578d50e494d328d5ffca94f56aea79c","tarball":"https://registry.npmjs.org/@adnsistemas/upng/-/upng-1.0.2.tgz","fileCount":8,"integrity":"sha512-FPfsaB7fW9+qzt7PSpnZCc4w9t+ywMH5IfPStad+ao/c6jsQxp699HEq8xiM+iIJGusoqjjhQZMwSJ7NeIKknw==","signatures":[{"sig":"MEUCIQCWQreyDTdhukd7lMkH8s5P3furg1hVV6KeBSv7H1tlzQIgco0NlgMU6XZhzY2uCjxNrylLOgBXujZp5vziTgSLfxQ=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":659452},"main":"cjs/UPNG.js","types":"index.d.ts","unpkg":"dist/UPNG.min.js","module":"UPNG.js","gitHead":"8695ace28efc4de25b6c88cc393b6c52cb4f9606","private":false,"scripts":{"build":"yarn build:cjs && yarn build:umd && yarn build:umd:min","release":"release-it","build:cjs":"babel --plugins @babel/plugin-transform-modules-commonjs --out-dir cjs UPNG.js","build:umd":"rollup --config rollup.config.js --file dist/UPNG.js","build:umd:min":"rollup --config rollup.config.js --file dist/UPNG.min.js --environment MINIFY"},"_npmUser":{"name":"adnsistemas","email":"dabdala@adnsistemas.com.ar"},"repository":{"url":"git+https://github.com/adnsistemas/upng.git","type":"git"},"_npmVersion":"10.8.2","description":"Small, fast and advanced PNG / APNG encoder and decoder","directories":{},"_nodeVersion":"20.17.0","dependencies":{"pako":"^1.0.10"},"publishConfig":{"registry":"https://registry.npmjs.org"},"_hasShrinkwrap":false,"packageManager":"yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e","devDependencies":{"rollup":"^1.31.1","@babel/cli":"^7.8.4","release-it":"^17.0.3","@babel/core":"^7.8.4","rollup-plugin-terser":"^5.1.3","@rollup/plugin-commonjs":"^11.0.0","@rollup/plugin-node-resolve":"^7.1.1","@babel/plugin-transform-modules-commonjs":"^7.8.3"},"_npmOperationalInternal":{"tmp":"tmp/upng_1.0.2_1764718633259_0.503920479375584","host":"s3://npm-registry-packages-npm-production"}},"1.0.3":{"name":"@adnsistemas/upng","version":"1.0.3","keywords":["png","apng","image","conversion"],"author":{"url":"https://github.com/photopea","name":"photopea"},"license":"MIT","_id":"@adnsistemas/upng@1.0.3","maintainers":[{"name":"adnsistemas","email":"dabdala@adnsistemas.com.ar"}],"contributors":[{"url":"https://github.com/Hopding","name":"Andrew Dillon"},{"url":"https://github.com/Scimonster","name":"Scimonster"},{"url":"https://github.com/thekonz","name":"Konstantin Duczek"},{"name":"David Abdala"}],"homepage":"https://github.com/adnsistemas/upng#readme","bugs":{"url":"https://github.com/adnsistemas/upng/issues"},"npm":{"publish":false},"dist":{"shasum":"240a014d09b32861d08560a59ca303b5499d7081","tarball":"https://registry.npmjs.org/@adnsistemas/upng/-/upng-1.0.3.tgz","fileCount":8,"integrity":"sha512-NFvcGsilB79BxXtGKT+oRjzG4Ksr4Dg4t00x//PQgiE4PtRmyA9vWCRdCNhMVmWXHkuimcC5mkyqvsbHiUJufA==","signatures":[{"sig":"MEYCIQDPeNeQiX+Bd6YhkVCoxT6genasw0xD05LJKwIfvINgywIhAM9Mz7E/fMFMlEZsHC748vFE1Iolcy/BHeyhTyMLvOBW","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":659694},"main":"cjs/UPNG.js","types":"index.d.ts","unpkg":"dist/UPNG.min.js","module":"UPNG.js","gitHead":"04328e0ea9965fcd6150a1fa97b6453d93caf9a1","private":false,"scripts":{"build":"yarn build:cjs && yarn build:umd && yarn build:umd:min","release":"release-it","build:cjs":"babel --plugins @babel/plugin-transform-modules-commonjs --out-dir cjs UPNG.js","build:umd":"rollup --config rollup.config.js --file dist/UPNG.js","build:umd:min":"rollup --config rollup.config.js --file dist/UPNG.min.js --environment MINIFY"},"_npmUser":{"name":"adnsistemas","email":"dabdala@adnsistemas.com.ar"},"repository":{"url":"git+https://github.com/adnsistemas/upng.git","type":"git"},"_npmVersion":"10.8.2","description":"Small, fast and advanced PNG / APNG encoder and decoder","directories":{},"_nodeVersion":"20.17.0","dependencies":{"pako":"^1.0.10"},"publishConfig":{"registry":"https://registry.npmjs.org"},"_hasShrinkwrap":false,"packageManager":"yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e","devDependencies":{"rollup":"^1.31.1","@babel/cli":"^7.8.4","release-it":"^17.0.3","@babel/core":"^7.8.4","rollup-plugin-terser":"^5.1.3","@rollup/plugin-commonjs":"^11.0.0","@rollup/plugin-node-resolve":"^7.1.1","@babel/plugin-transform-modules-commonjs":"^7.8.3"},"_npmOperationalInternal":{"tmp":"tmp/upng_1.0.3_1764721968893_0.21991615458198477","host":"s3://npm-registry-packages-npm-production"}},"1.0.4":{"name":"@adnsistemas/upng","license":"MIT","version":"1.0.4","description":"Small, fast and advanced PNG / APNG encoder and decoder","main":"cjs/UPNG.js","unpkg":"dist/UPNG.min.js","module":"UPNG.js","types":"index.d.ts","scripts":{"release":"release-it","build":"yarn build:cjs && yarn build:umd && yarn build:umd:min","build:cjs":"babel --plugins @babel/plugin-transform-modules-commonjs --out-dir cjs UPNG.js","build:umd":"rollup --config rollup.config.js --file dist/UPNG.js","build:umd:min":"rollup --config rollup.config.js --file dist/UPNG.min.js --environment MINIFY"},"repository":{"type":"git","url":"git+https://github.com/adnsistemas/upng.git"},"author":{"name":"photopea","url":"https://github.com/photopea"},"contributors":[{"name":"Andrew Dillon","url":"https://github.com/Hopding"},{"name":"Scimonster","url":"https://github.com/Scimonster"},{"name":"Konstantin Duczek","url":"https://github.com/thekonz"},{"name":"David Abdala"}],"bugs":{"url":"https://github.com/adnsistemas/upng/issues"},"keywords":["png","apng","image","conversion"],"dependencies":{"pako":"^1.0.10"},"devDependencies":{"@babel/cli":"^7.8.4","@babel/core":"^7.8.4","@babel/plugin-transform-modules-commonjs":"^7.8.3","release-it":"^17.0.3","@rollup/plugin-commonjs":"^11.0.0","@rollup/plugin-node-resolve":"^7.1.1","rollup":"^1.31.1","rollup-plugin-terser":"^5.1.3"},"private":false,"npm":{"publish":false},"publishConfig":{"registry":"https://registry.npmjs.org"},"packageManager":"yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e","_id":"@adnsistemas/upng@1.0.4","gitHead":"9c90a864a12be5fa2fc06e14d5b365cf6f070ccb","homepage":"https://github.com/adnsistemas/upng#readme","_nodeVersion":"20.17.0","_npmVersion":"10.8.2","dist":{"integrity":"sha512-adiWnrw74mdvjn83B+BIL3rCwaM9+Da2i5btwWaJUS3RmwcwuAfwnY20RI+qgnD7Jc/pvEGy8AfweDNbkXMLQg==","shasum":"04328d7e064103243f03da58d7e19bb769465ea7","tarball":"https://registry.npmjs.org/@adnsistemas/upng/-/upng-1.0.4.tgz","fileCount":8,"unpackedSize":659740,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDCdiOuIYC9Z2ezemA7Cxz0oNHdHVaVgV1k/4Lz6wlb9wIhAMaNYJCUqecO7t6L+Zc/AE3/tojL4NOSTCBDmDeyYjX7"}]},"_npmUser":{"name":"adnsistemas","email":"dabdala@adnsistemas.com.ar"},"directories":{},"maintainers":[{"name":"adnsistemas","email":"dabdala@adnsistemas.com.ar"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/upng_1.0.4_1771713894329_0.9155104196140613"},"_hasShrinkwrap":false}},"time":{"created":"2025-12-02T23:36:41.001Z","modified":"2026-02-21T22:44:54.651Z","1.0.1":"2025-12-02T23:36:41.288Z","1.0.2":"2025-12-02T23:37:13.509Z","1.0.3":"2025-12-03T00:32:49.155Z","1.0.4":"2026-02-21T22:44:54.541Z"},"bugs":{"url":"https://github.com/adnsistemas/upng/issues"},"author":{"name":"photopea","url":"https://github.com/photopea"},"license":"MIT","homepage":"https://github.com/adnsistemas/upng#readme","keywords":["png","apng","image","conversion"],"repository":{"type":"git","url":"git+https://github.com/adnsistemas/upng.git"},"description":"Small, fast and advanced PNG / APNG encoder and decoder","contributors":[{"name":"Andrew Dillon","url":"https://github.com/Hopding"},{"name":"Scimonster","url":"https://github.com/Scimonster"},{"name":"Konstantin Duczek","url":"https://github.com/thekonz"},{"name":"David Abdala"}],"maintainers":[{"name":"adnsistemas","email":"dabdala@adnsistemas.com.ar"}],"readme":"<h1>\n  upng\n\n  <br />\n\n  <!-- NPM Version -->\n  <a href=\"https://www.npmjs.com/package/@adnsistemas/upng\">\n    <img\n      src=\"https://img.shields.io/npm/v/@adnsistemas/upng.svg?style=flat-square\"\n      alt=\"NPM Version\"\n    />\n  </a>\n</h1>\n\n> A small, fast and advanced PNG / APNG encoder and decoder\n\nThis project is a fork of [`UPNG.js`](https://github.com/photopea/UPNG.js) and was created for use in [`@adnsistemas/pdf-lib`](https://github.com/adnsistemas/pdf-lib). The maintainer of the original repo does not publish it to NPM. That is the primary purpose of this fork. In addition, an `index.d.ts` file has been added (copied directly from [`@types/upng-js`](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/upng-js/index.d.ts)) to makes TypeScript definitions available without requiring additional packages to be installed.  \nThe original package [`@pdf-lib/upng`](https://github.com/Hopdig/upng) was modified to be able to use it in ESM and CommonJS projects.\n\n## Example of `UPNG.toRGBA8`\n```javascript\n// Import the UPNG class\nimport UPNG from '@adnsistemas/upng';\n\n// Create a UPNG object\nconst pngImage = UPNG.decode(/* Uint8Array containing bytes of PNG image */);\n\n// `pixels` is a 1D array (in rgba order) of decoded pixel data\nconst pixels = pngImage.UPNG.toRGBA8();\n```\n\n## Installation\n### NPM Module\nTo install the latest stable version:\n```bash\n# With npm\nnpm install --save @adnsistemas/upng\n\n# With yarn\nyarn add @adnsistemas/upng\n```\nThis assumes you're using [npm](https://www.npmjs.com/) or [yarn](https://yarnpkg.com/lang/en/) as your package manager.\n\n### UMD Module\nYou can also download `@pdf-lib/upng` as a UMD module from [unpkg](https://unpkg.com/#/). The UMD builds have been compiled to ES5, so they should work [in any modern browser](https://caniuse.com/#feat=es5). UMD builds are useful if you aren't using a package manager or module bundler. For example, you can use them directly in the `<script>` tag of an HTML page.\n\nThe following builds are available:\n\n* https://unpkg.com/@pdf-lib/upng/dist/UPNG.js\n* https://unpkg.com/@pdf-lib/upng/dist/UPNG.min.js\n\nWhen using a UMD build, you will have access to a global `window.UPNG` variable. This variable contains the `UPNG` class exported by `@pdf-lib/upng`. For example:\n\n```javascript\n// NPM module\nimport UPNG from '@pdf-lib/upng';\nconst pngImage = UPNG.decode(/* ... */)\n\n// UMD module\nvar pngImage = window.UPNG.decode(/* ... */)\n```\n\n\n## Encoder\n\nUPNG.js supports APNG and the interface expects \"frames\". Regular PNG is just a single-frame animation (single-item array).\n\n#### `UPNG.encode(imgs, w, h, cnum, [dels], [tabs])`\n* `imgs`: array of frames. A frame is an ArrayBuffer containing the pixel data (RGBA, 8 bits per channel)\n* `w`, `h` : width and height of the image\n* `cnum`: number of colors in the result;  0: all colors (lossless PNG)\n* `dels`: array of millisecond delays for each frame (only when 2 or more frames)\n* `tabs`: object of options. `{ loop: 1 }` will play the animation only once (default is `0`, will play indefinitely).\n* returns an ArrayBuffer with binary data of a PNG file\n\nUPNG.js can do a lossy minification of PNG files, similar to [TinyPNG](https://tinypng.com/) and other tools. It performed quantization with [k-means algorithm](https://en.wikipedia.org/wiki/K-means_clustering) in the past, but now we use [K-d trees](https://en.wikipedia.org/wiki/K-d_tree).\n\nLossy compression is allowed by the last parameter `cnum`. Set it to zero for a lossless compression, or write the number of allowed colors in the image. Smaller values produce smaller files. **Or just use 0 for lossless / 256 for lossy.**\n\n    // Read RGBA from canvas and encode with UPNG\n    var dta = ctx.getImageData(0,0,200,300).data;  // ctx is Context2D of a Canvas\n    //  dta = new Uint8Array(200 * 300 * 4);       // or generate pixels manually\n    var png = UPNG.encode([dta.buffer], 200, 300, 0);   console.log(new Uint8Array(png));\n\n#### `UPNG.encodeLL(imgs, w, h, cc, ac, depth, [dels])` - low-level encode\n* `imgs`: array of frames. A frame is an ArrayBuffer containing the pixel data (corresponding to following parameters)\n* `w`, `h` : width and height of the image\n* `cc`, `ac`: number of color channels (1 or 3) and alpha channels (0 or 1)\n* `depth`: bit depth of pixel data (1, 2, 4, 8, 16)\n* `dels`: array of millisecond delays for each frame (only when 2 or more frames)\n* returns an ArrayBuffer with binary data of a PNG file\n\nThis function does not do any optimizations, it just stores what you give it. There are two cases when it is useful:\n* saving 16-bit colors (note, that PNG is big-endian, unlike Uint16Array in JS)\n* your image is too large, and \"expanding\" to 8-bit RGBA would use too much memory (e.g. 4-bit grayscale 50,000 x 50,000 = 1.25 GB, 8-bit RGBA would be 10 GB)\n\n## Decoder\n\nSupports all color types (including Grayscale and Palettes), all channel depths (1, 2, 4, 8, 16), interlaced images etc. Opens PNGs which other libraries can not open (tested with [PngSuite](http://www.schaik.com/pngsuite/)).\n\n#### `UPNG.decode(buffer)`\n* `buffer`: ArrayBuffer containing the PNG file\n* returns an image object with following properties:\n* * `width`: the width of the image\n* * `height`: the height of the image\n* * `depth`: number of bits per channel\n* * `ctype`: color type of the file (Truecolor, Grayscale, Palette ...)\n* * `frames`: additional info about frames (frame delays etc.)\n* * `tabs`: additional chunks of the PNG file\n* * `data`: pixel data of the image\n\nPNG files may have a various number of channels and a various color depth. The interpretation of `data` depends on the current color type and color depth (see the [PNG specification](https://www.w3.org/TR/PNG/)).\n\n#### `UPNG.toRGBA8(img)`\n* `img`: PNG image object (returned by UPNG.decode())\n* returns an array of frames. A frame is ArrayBuffer of the image in RGBA format, 8 bits per channel.\n\n### Example\n    var img  = UPNG.decode(buff);        // put ArrayBuffer of the PNG file into UPNG.decode\n    var rgba = UPNG.toRGBA8(img)[0];     // UPNG.toRGBA8 returns array of frames, size: width * height * 4 bytes.\n\nPNG format uses the Inflate algorithm. Right now, UPNG.js calls [Pako.js](https://github.com/nodeca/pako) for the Inflate and Deflate method.\n\n## Quantizer\n\nUPNG.js contains a very good Quantizer of 4-component 8-bit vectors (i.e. pixels). It can be used to generate nice color palettes (e.g. Photopea uses UPNG.js to make palettes for GIF images).\n\nQuantization consists of two important steps: Finding a nice palette and Finding the closest color in the palette for each sample (non-trivial for large palettes). UPNG perfroms both steps.\n\n    var res  = UPNG.quantize(data, psize);\n\n* `data`: ArrayBuffer of samples (byte length is a multiple of four)\n* `psize` : Palette size (how many colors you want to have)\n\nThe result object \"res\" has following properties:\n\n* `abuf`: ArrayBuffer corresponding to `data`, where colors are remapped by a palette\n* `inds`: Uint8Array : the index of a color for each sample (only when `psize`<=256)\n* `plte`: Array : the Palette - a list of colors, `plte[i].est.q` and `plte[i].est.rgba` is the color value\n\n### FAQ\n\n- To get one common palette for multiple images (e.g. frames of the animation), concatenate them into one array `data`.\n- When working with less than four components, set the remaining components to a constant value (e.g. to zero)\n- When working with transparency, premultiply color components by transparency (otherwise, rgba(1,1,1,0) would be closer to rgba(1,1,1,1) than to rgba(0,0,0,0) - transparent mapped to white instead of transparent)\n","readmeFilename":"README.md"}