{"versions":{"0.0.0-stage":{"name":"@jimp/pngjs","version":"0.0.0-stage","_id":"@jimp/pngjs@0.0.0-stage","stub":true,"maintainers":[{"name":"anonymous","email":"lisowski54@gmail.com"}],"dist":{"shasum":"4e4f74f0a039818b055de8131487fa266e753f6c","tarball":"http://123.232.10.234:8212/nexus/content/repositories/npm-private/@jimp/pngjs/-/pngjs-0.0.0-stage.tgz","fileCount":2,"integrity":"sha512-3XXNH/+erHqRUlAJ/tyeWH1NIhr6oQqIdOuRNnv29F+JtjTiOpPv2+j8gqbAq6nXgTYvKqogQNg3m5HeGUnEdw==","signatures":[{"sig":"MEQCIHjuykV9q+ogO1lr8HiY/9hHssrgRNLEcIODPOxtS7rMAiB8ltuY7ZZLatxVyw9ZQJNmGCredxfARV/kBE9Yt/mnQA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":333,"size":365},"_npmUser":{"name":"anonymous","email":"lisowski54@gmail.com"},"description":"Temporary package placeholder for staged publishing","directories":{},"_cnpmcore_publish_time":"2026-11-24T23:21:01.839Z","publish_time":1795562461839,"_hasShrinkwrap":false,"_source_registry_name":"default","contributors":[]},"2.2.0":{"_id":"@jimp/pngjs@2.2.0","bugs":{"url":"https://github.com/jimp-dev/jimp/issues"},"dist":{"shasum":"9475165cc1cb9da085f519a46add4de3fa5f4009","tarball":"http://123.232.10.234:8212/nexus/content/repositories/npm-private/@jimp/pngjs/-/pngjs-2.2.0.tgz","fileCount":258,"integrity":"sha512-ojef1Azxh2OUxRsTlOpYFW7Hr1ljvArBeR5IRgZEKMClzbMCyjSnFYdu2wds4AccaDlSB+Y1slcUvDGkWl5y3Q==","signatures":[{"sig":"MEUCIEDPgsL1exiwKHDiITnK2CAQ0Qwj9P2OfwSMl5X7jfqnAiEAussV09jaRAs/MDcHhahi13R0F3MOJ0qdCB5nmIw+mJI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIDP7c0f/8mDo6tLUtwv6mzzEpx8u/N3U5gYLbL8YdEZ7AiAii0GypL6dr2RsDvqKCb82W2k2RkgpqFEPJZBNgiiNpA=="}],"unpackedSize":1081960,"size":117936},"main":"./dist/commonjs/index.js","name":"@jimp/pngjs","tshy":{"exclude":["**/*.test.ts"],"exports":{".":"./src/index.ts","./package.json":"./package.json"},"esmDialects":["browser"]},"type":"module","types":"./dist/commonjs/index.d.ts","author":{"name":"Andrew Lisowski","email":"lisowski54@gmail.com"},"module":"./dist/esm/index.js","engines":{"node":">=22"},"exports":{".":{"import":{"types":"./dist/esm/index.d.ts","default":"./dist/esm/index.js"},"browser":{"types":"./dist/browser/index.d.ts","default":"./dist/browser/index.js"},"require":{"types":"./dist/commonjs/index.d.ts","default":"./dist/commonjs/index.js"}},"./package.json":"./package.json"},"gitHead":"3308bdef5bcf1a8ef868bd3a5abf5105c993e060","license":"MIT","scripts":{"dev":"tshy --watch","lint":"eslint .","test":"vitest","bench":"node bench/bench.mjs","build":"tshy","clean":"rimraf node_modules .tshy .tshy-build dist .turbo","test:browser":"vitest --config vitest.config.browser.mjs"},"version":"2.2.0","_npmUser":{"name":"anonymous","email":"lisowski54@gmail.com"},"homepage":"https://github.com/jimp-dev/jimp#readme","keywords":["png","pngjs","decoder","encoder","image"],"repository":{"url":"git+https://github.com/jimp-dev/jimp.git","type":"git"},"_npmVersion":"lerna/10.1.3/node@v24.15.0+arm64 (darwin)","description":"PNG encoder and decoder in pure JavaScript, for Node.js and browsers. A maintained fork of pngjs.","directories":{},"maintainers":[{"name":"anonymous","email":"lisowski54@gmail.com"},{"name":"anonymous","email":"oliver@nth-iteration.ie"}],"sideEffects":false,"_nodeVersion":"24.15.0","contributors":[{"name":"Luke Page"},{"name":"Kuba Niegowski"},{"name":"Alexandre Paré"},{"name":"Gaurav Mali"},{"name":"Gusts Kaksis"},{"name":"Pietajan De Potter"},{"name":"Steven Sojka"},{"name":"liangzeng"},{"name":"Michael Vogt"},{"name":"Xin-Xin Wang"},{"name":"toriningen"},{"name":"Eugene Kulabuhov"}],"dependencies":{"pako":"^3.0.3"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tshy":"~4.0.0","pngjs":"^7.0.0","eslint":"^10.15.0","vitest":"^5.1.1","typescript":"^7.0.2","@types/node":"^22.20.5","@types/pngjs":"^6.0.5","@jimp/config-eslint":"2.2.0","@jimp/config-typescript":"2.2.0","@vitest/browser-playwright":"^5.1.1"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/pngjs_2.2.0_1795629169138_0.717240426513795"},"_cnpmcore_publish_time":"2026-11-25T17:52:49.240Z","publish_time":1795629169240,"_source_registry_name":"default"},"2.1.0":{"name":"@jimp/pngjs","version":"2.1.0","keywords":["png","pngjs","decoder","encoder","image"],"author":{"name":"Andrew Lisowski","email":"lisowski54@gmail.com"},"license":"MIT","_id":"@jimp/pngjs@2.1.0","maintainers":[{"name":"anonymous","email":"lisowski54@gmail.com"},{"name":"anonymous","email":"oliver@nth-iteration.ie"}],"contributors":[{"name":"Luke Page"},{"name":"Kuba Niegowski"},{"name":"Alexandre Paré"},{"name":"Gaurav Mali"},{"name":"Gusts Kaksis"},{"name":"Pietajan De Potter"},{"name":"Steven Sojka"},{"name":"liangzeng"},{"name":"Michael Vogt"},{"name":"Xin-Xin Wang"},{"name":"toriningen"},{"name":"Eugene Kulabuhov"}],"homepage":"https://github.com/jimp-dev/jimp#readme","bugs":{"url":"https://github.com/jimp-dev/jimp/issues"},"dist":{"shasum":"43b014d2be6ffd0f52a79efa9635249dd702a9a5","tarball":"http://123.232.10.234:8212/nexus/content/repositories/npm-private/@jimp/pngjs/-/pngjs-2.1.0.tgz","fileCount":258,"integrity":"sha512-e8McZcm5g6NbK1S0WQd4ZUo3saiVNdvblfRnvunsiwxhEBiccI+6Ncqxjzq8vOB5ibsvzDFhGYgW+rCC1rAeDw==","signatures":[{"sig":"MEYCIQDsb9VBgNrUVTG+42k2PVdRoIYXO5OR0s/vlen+eQmn6gIhAPkDlXBT/cJNsLGwrC3GJKVT35kF9TxGDLMntgx61gNo","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"sig":"MEUCIQC67m3vEuJm9gR9ROXvj4lI7hUXduPAQ7Uplijp2jDHuAIgBZI09pXAWP/UfV+Jfy9PXx0hUSfLZbOy8gPjuJxnQYw=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":1081960,"size":117935},"main":"./dist/commonjs/index.js","tshy":{"exclude":["**/*.test.ts"],"exports":{".":"./src/index.ts","./package.json":"./package.json"},"esmDialects":["browser"]},"type":"module","types":"./dist/commonjs/index.d.ts","module":"./dist/esm/index.js","engines":{"node":">=22"},"exports":{".":{"import":{"types":"./dist/esm/index.d.ts","default":"./dist/esm/index.js"},"browser":{"types":"./dist/browser/index.d.ts","default":"./dist/browser/index.js"},"require":{"types":"./dist/commonjs/index.d.ts","default":"./dist/commonjs/index.js"}},"./package.json":"./package.json"},"gitHead":"8346e2329163e0c3ee26aaf8fe1001bac8b25a21","scripts":{"dev":"tshy --watch","lint":"eslint .","test":"vitest","bench":"node bench/bench.mjs","build":"tshy","clean":"rimraf node_modules .tshy .tshy-build dist .turbo","test:browser":"vitest --config vitest.config.browser.mjs"},"_npmUser":{"name":"anonymous","email":"lisowski54@gmail.com"},"repository":{"url":"git+https://github.com/jimp-dev/jimp.git","type":"git"},"_npmVersion":"lerna/10.1.3/node@v24.15.0+arm64 (darwin)","description":"PNG encoder and decoder in pure JavaScript, for Node.js and browsers. A maintained fork of pngjs.","directories":{},"sideEffects":false,"_nodeVersion":"24.15.0","dependencies":{"pako":"^3.0.3"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tshy":"~4.0.0","pngjs":"^7.0.0","eslint":"^10.15.0","vitest":"^5.1.1","typescript":"^7.0.2","@types/node":"^22.20.5","@types/pngjs":"^6.0.5","@jimp/config-eslint":"2.1.0","@jimp/config-typescript":"2.1.0","@vitest/browser-playwright":"^5.1.1"},"_npmOperationalInternal":{"tmp":"tmp/pngjs_2.1.0_1795562588291_0.7468460507978963","host":"s3://npm-registry-packages-npm-production"},"_cnpmcore_publish_time":"2026-11-24T23:23:08.410Z","publish_time":1795562588410,"_source_registry_name":"default"},"2.2.1":{"_id":"@jimp/pngjs@2.2.1","bugs":{"url":"https://github.com/jimp-dev/jimp/issues"},"dist":{"shasum":"7f12f6c272134094be89d86577aca60f2e458427","tarball":"http://123.232.10.234:8212/nexus/content/repositories/npm-private/@jimp/pngjs/-/pngjs-2.2.1.tgz","fileCount":258,"integrity":"sha512-9z1ZAzpsjRUYamilYrxyfdNFTBi2i0mcahZ8V2+A/pAWs8YV/LlHztnYA/IDx8XG9qlwVL6FjrjdLckHYHxx7g==","signatures":[{"sig":"MEQCIH9FutTDyXqgKdcvQ3+lyK91wIG1+sesErqx7/tr3BEVAiADTKmjKMFe74XGd3YPrEaCGbPnqe/C3pOPlRKAC79THg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCATgZ/UDSHkdnMxTO0pKGLRxtDWLE6n8B9GfFipF0DkwIhAMpwVAeH4zpRPDDp6PZJzmvSMhhcaxkscDVfZTPy2DxN"}],"unpackedSize":1081960,"size":117936},"main":"./dist/commonjs/index.js","name":"@jimp/pngjs","tshy":{"exclude":["**/*.test.ts"],"exports":{".":"./src/index.ts","./package.json":"./package.json"},"esmDialects":["browser"]},"type":"module","types":"./dist/commonjs/index.d.ts","author":{"name":"Andrew Lisowski","email":"lisowski54@gmail.com"},"module":"./dist/esm/index.js","engines":{"node":">=22"},"exports":{".":{"import":{"types":"./dist/esm/index.d.ts","default":"./dist/esm/index.js"},"browser":{"types":"./dist/browser/index.d.ts","default":"./dist/browser/index.js"},"require":{"types":"./dist/commonjs/index.d.ts","default":"./dist/commonjs/index.js"}},"./package.json":"./package.json"},"gitHead":"7ab3ff96f32a76e547be763bbafd474226429103","license":"MIT","scripts":{"dev":"tshy --watch","lint":"eslint .","test":"vitest","bench":"node bench/bench.mjs","build":"tshy","clean":"rimraf node_modules .tshy .tshy-build dist .turbo","test:browser":"vitest --config vitest.config.browser.mjs"},"version":"2.2.1","_npmUser":{"name":"anonymous","email":"lisowski54@gmail.com"},"homepage":"https://github.com/jimp-dev/jimp#readme","keywords":["png","pngjs","decoder","encoder","image"],"repository":{"url":"git+https://github.com/jimp-dev/jimp.git","type":"git"},"_npmVersion":"lerna/10.1.3/node@v24.15.0+arm64 (darwin)","description":"PNG encoder and decoder in pure JavaScript, for Node.js and browsers. A maintained fork of pngjs.","directories":{},"maintainers":[{"name":"anonymous","email":"lisowski54@gmail.com"},{"name":"anonymous","email":"oliver@nth-iteration.ie"}],"sideEffects":false,"_nodeVersion":"24.15.0","contributors":[{"name":"Luke Page"},{"name":"Kuba Niegowski"},{"name":"Alexandre Paré"},{"name":"Gaurav Mali"},{"name":"Gusts Kaksis"},{"name":"Pietajan De Potter"},{"name":"Steven Sojka"},{"name":"liangzeng"},{"name":"Michael Vogt"},{"name":"Xin-Xin Wang"},{"name":"toriningen"},{"name":"Eugene Kulabuhov"}],"dependencies":{"pako":"^3.0.3"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tshy":"~4.0.0","pngjs":"^7.0.0","eslint":"^10.15.0","vitest":"^5.1.1","typescript":"^7.0.2","@types/node":"^22.20.5","@types/pngjs":"^6.0.5","@jimp/config-eslint":"2.2.1","@jimp/config-typescript":"2.2.1","@vitest/browser-playwright":"^5.1.1"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/pngjs_2.2.1_1795814477666_0.15611765798144062"},"_cnpmcore_publish_time":"2026-11-27T21:21:17.825Z","publish_time":1795814477825,"_source_registry_name":"default"},"2.2.2":{"_id":"@jimp/pngjs@2.2.2","bugs":{"url":"https://github.com/jimp-dev/jimp/issues"},"dist":{"shasum":"63d66dde9898e9773aa40d7c878c0faca4ad8b63","tarball":"http://123.232.10.234:8212/nexus/content/repositories/npm-private/@jimp/pngjs/-/pngjs-2.2.2.tgz","fileCount":258,"integrity":"sha512-sbDmSbOV9rkxSzhM8X+aPJXuN1h8B/IV4aQUdFVGhCWTXel6jVDE/RajWDEyRgi0XDOJkXBEVJLLDmaN4KRpvQ==","signatures":[{"sig":"MEUCIQD6mzgGTkIaSN8IPN/ltR1Wc8xGaFouz0IQ5nMOzxeQMgIgd4kTIci1L4t7ECI9xQE0N15IiKuSWrydv49bcNL6yHE=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIFNJjnO+ztkqcf5f45yDehmUT0KVgdxysCrY2sJFU2LoAiAZFg5D0LDa+l9+I+DeHIuVPYDTm/nsAfVvKFN/KI8kEQ=="}],"unpackedSize":1081960,"size":117937},"main":"./dist/commonjs/index.js","name":"@jimp/pngjs","tshy":{"exclude":["**/*.test.ts"],"exports":{".":"./src/index.ts","./package.json":"./package.json"},"esmDialects":["browser"]},"type":"module","types":"./dist/commonjs/index.d.ts","author":{"name":"Andrew Lisowski","email":"lisowski54@gmail.com"},"module":"./dist/esm/index.js","engines":{"node":">=22"},"exports":{".":{"import":{"types":"./dist/esm/index.d.ts","default":"./dist/esm/index.js"},"browser":{"types":"./dist/browser/index.d.ts","default":"./dist/browser/index.js"},"require":{"types":"./dist/commonjs/index.d.ts","default":"./dist/commonjs/index.js"}},"./package.json":"./package.json"},"gitHead":"d18cc93e6e0d1765ca72b19c22f2aa94dc183981","license":"MIT","scripts":{"dev":"tshy --watch","lint":"eslint .","test":"vitest","bench":"node bench/bench.mjs","build":"tshy","clean":"rimraf node_modules .tshy .tshy-build dist .turbo","test:browser":"vitest --config vitest.config.browser.mjs"},"version":"2.2.2","_npmUser":{"name":"anonymous","email":"lisowski54@gmail.com"},"homepage":"https://github.com/jimp-dev/jimp#readme","keywords":["png","pngjs","decoder","encoder","image"],"repository":{"url":"git+https://github.com/jimp-dev/jimp.git","type":"git"},"_npmVersion":"lerna/10.1.3/node@v24.15.0+arm64 (darwin)","description":"PNG encoder and decoder in pure JavaScript, for Node.js and browsers. A maintained fork of pngjs.","directories":{},"maintainers":[{"name":"anonymous","email":"lisowski54@gmail.com"},{"name":"anonymous","email":"oliver@nth-iteration.ie"}],"sideEffects":false,"_nodeVersion":"24.15.0","contributors":[{"name":"Luke Page"},{"name":"Kuba Niegowski"},{"name":"Alexandre Paré"},{"name":"Gaurav Mali"},{"name":"Gusts Kaksis"},{"name":"Pietajan De Potter"},{"name":"Steven Sojka"},{"name":"liangzeng"},{"name":"Michael Vogt"},{"name":"Xin-Xin Wang"},{"name":"toriningen"},{"name":"Eugene Kulabuhov"}],"dependencies":{"pako":"^3.0.3"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tshy":"~4.0.0","pngjs":"^7.0.0","eslint":"^10.15.0","vitest":"^5.1.1","typescript":"^7.0.2","@types/node":"^22.20.5","@types/pngjs":"^6.0.5","@jimp/config-eslint":"2.2.2","@jimp/config-typescript":"2.2.2","@vitest/browser-playwright":"^5.1.1"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/pngjs_2.2.2_1796011954473_0.2820402876776581"},"_cnpmcore_publish_time":"2026-11-30T04:12:34.597Z","publish_time":1796011954597,"_source_registry_name":"default"}},"dist-tags":{"latest":"2.2.2"},"name":"@jimp/pngjs","time":{"created":"2026-11-25T17:52:59.808Z","modified":"2026-11-30T04:12:46.226Z","0.0.0-stage":"2026-11-24T23:21:01.839Z","2.2.0":"2026-11-25T17:52:49.240Z","2.1.0":"2026-11-24T23:23:08.410Z","2.2.1":"2026-11-27T21:21:17.825Z","2.2.2":"2026-11-30T04:12:34.597Z"},"readme":"<div align=\"center\">\n  <img width=\"140\" alt=\"\"\n    src=\"https://raw.githubusercontent.com/jimp-dev/jimp/main/.github/assets/jimpy.png\">\n  <h1>@jimp/pngjs</h1>\n  <p>A PNG encoder and decoder in pure JavaScript, for Node.js and browsers.</p>\n</div>\n\n- Decodes every PNG: all bit depths (1, 2, 4, 8, 16), colour types, interlacing and transparency, checked pixel for pixel against libpng on [PngSuite](http://www.schaik.com/pngsuite/)\n- Encodes to the smallest lossless format by default, including palettes and 1, 2 and 4-bit grayscale\n- Decodes APNG animations\n- Reads and writes metadata: text, pHYs, gamma, sRGB, ICC profiles and EXIF\n- Sync, with no Node.js polyfills in browsers\n- A drop-in replacement for [pngjs](https://github.com/pngjs/pngjs), with its bugs fixed, and faster\n\n## Based on pngjs\n\nThis package is a fork of [pngjs](https://github.com/pngjs/pngjs) 7.0.0 by\nLuke Page and the pngjs contributors, which is in turn based on\n[node-pngjs](https://github.com/niegowski/node-pngjs) by Kuba Niegowski. It\nwas rewritten in TypeScript, but keeps pngjs's API, and its encoder writes the\nsame bytes for the same settings. pngjs's MIT license and copyright notices\nare in [LICENSE](./LICENSE).\n\npngjs hasn't had a release since 2023. This fork fixes the bugs in its issue\ntracker ([see below](#fixed-from-pngjs)) and is maintained as part of\n[Jimp](https://github.com/jimp-dev/jimp).\n\n## Install\n\n```sh\nnpm install @jimp/pngjs\n```\n\n## Usage\n\n```js\nimport { decode, encode } from \"@jimp/pngjs\";\n\nconst image = decode(fs.readFileSync(\"in.png\"));\n// { width, height, data, depth, colorType, interlace, gamma, text, ... }\n\n// Invert the colours\nfor (let i = 0; i < image.data.length; i += 4) {\n  image.data[i] = 255 - image.data[i];\n  image.data[i + 1] = 255 - image.data[i + 1];\n  image.data[i + 2] = 255 - image.data[i + 2];\n}\n\nfs.writeFileSync(\"out.png\", encode(image));\n```\n\nBoth work on bytes: a `Uint8Array` (or `Buffer`) or an `ArrayBuffer` in, a\n`Uint8Array` out (a `Buffer` in Node.js). In a browser:\n\n```js\nconst response = await fetch(\"image.png\");\nconst image = decode(await response.arrayBuffer());\n```\n\n### `decode(data, options?)`\n\nDecodes a PNG to RGBA pixels, row by row, 8 bits per sample. Returns:\n\n| Property           | Description                                                                                     |\n| ------------------ | ----------------------------------------------------------------------------------------------- |\n| `width`, `height`  | The size in pixels                                                                              |\n| `data`             | The pixels as R, G, B, A samples: a `Uint8Array`, or a `Uint16Array` with `outputDepth: 16`     |\n| `depth`            | The file's bit depth: 1, 2, 4, 8 or 16                                                          |\n| `colorType`        | The file's colour type, a `ColorType`                                                           |\n| `interlace`        | Whether the file is interlaced                                                                  |\n| `palette`          | The palette of palette images, as `[r, g, b, a]` entries                                        |\n| `transparentColor` | The tRNS colour of grayscale and colour images, at the file's bit depth                         |\n| `gamma`            | The gAMA chunk's gamma, e.g. `0.45455`                                                          |\n| `srgb`             | The sRGB chunk's rendering intent                                                               |\n| `iccProfile`       | The iCCP chunk: `{ name, data }`, with the profile uncompressed                                 |\n| `physical`         | The pHYs chunk: `{ x, y, unit }`, pixels per unit, with `unit` `\"meter\"` or `\"unknown\"`         |\n| `text`             | The tEXt, zTXt and iTXt chunks: `{ keyword, text, compressed?, language?, translatedKeyword? }` |\n| `exif`             | The eXIf chunk's EXIF data                                                                      |\n\nOptions:\n\n- `checkCRC` (default `true`): check each chunk's CRC. A wrong CRC in a chunk\n  the image needs throws, while metadata chunks with one are skipped.\n- `outputDepth` (default `8`): `16` decodes to 16-bit samples in a\n  `Uint16Array`, which keeps the precision of 16-bit images.\n\nErrors throw an `Error` that says what's wrong, e.g. `Invalid file signature:\nnot a PNG file` or `Not enough image data: expected 4128 bytes, got 1000`.\nLike browsers, the decoder doesn't mind data after the end of the file, a\nmissing IEND chunk, a wrong zlib checksum or broken metadata chunks.\n\n### `encode(image, options?)`\n\nEncodes `{ width, height, data }`, with `data` as RGBA samples: 8 bits each in\na `Uint8Array` (or `Buffer`), or 16 bits each in a `Uint16Array`.\n\nBy default it writes the smallest format that keeps every pixel as it is:\n\n| Image                               | Written as                                          |\n| ----------------------------------- | --------------------------------------------------- |\n| Every pixel opaque and gray         | Grayscale, at 1, 2, 4 or 8 bits if the levels allow |\n| 256 colours or fewer                | A palette, at 1, 2, 4 or 8 bits                     |\n| Every pixel opaque                  | RGB                                                 |\n| Every pixel gray, some transparent  | Gray and alpha                                      |\n| Anything else                       | RGBA                                                |\n| 16-bit data that doesn't fit 8 bits | The same, at 16 bits (no palette)                   |\n\n| Option                                                    | Default   | Description                                                                                                                                                                                    |\n| --------------------------------------------------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `colorType`                                               | smallest  | A `ColorType`. Converting colour to gray uses the mean of R, G and B.                                                                                                                          |\n| `bitDepth`                                                | smallest  | 1, 2, 4, 8 or 16, if the colour type allows it                                                                                                                                                 |\n| `filterType`                                              | `-1`      | `-1` (`FilterType.AUTO`) picks the best filter for each line. A filter type 0-4, or a list of them to pick from. Palette and low bit depth images default to `0`, as filters rarely help them. |\n| `deflateLevel`                                            | `9`       | zlib's compression level, 0-9                                                                                                                                                                  |\n| `deflateStrategy`                                         | `3`       | zlib's strategy. 3 (run-length) is fast. 0 or 1 are a little smaller and much slower.                                                                                                          |\n| `interlace`                                               | `false`   | Write an Adam7 interlaced PNG                                                                                                                                                                  |\n| `background`                                              | white     | `{ red, green, blue }` to blend transparent pixels with when the colour type has no alpha                                                                                                      |\n| `idatChunkSize`                                           | one chunk | Split the image data into IDAT chunks of at most this many bytes                                                                                                                               |\n| `gamma`, `srgb`, `iccProfile`, `physical`, `text`, `exif` |           | Metadata to write, as `decode` returns it                                                                                                                                                      |\n\n### `decodeFrames(data, options?)`\n\nDecodes every frame of an animated PNG (APNG). Each frame is the whole image\nat that point of the animation, with the frames before it drawn underneath as\nthe animation says. Returns `{ width, height, frames: [{ data, delay }], plays }`,\nwith `delay` in milliseconds and `plays` the number of times the animation\nplays, 0 for forever. A PNG that isn't animated has one frame and no `plays`.\n\nTakes `decode`'s options, and `maxFrames` to stop early. `decode` returns the\nimage viewers without APNG support show.\n\n### `readHeader(data)`\n\nReads the IHDR chunk: `{ width, height, depth, colorType, interlace }`, without\ndecoding anything else.\n\n### `adjustGamma(image, displayGamma = 2.2)`\n\nApplies the image's `gamma` to its pixels for a display with the given gamma,\nand sets `gamma` to 0. For 16-bit images, use it on the `outputDepth: 16`\npixels, which keeps the precision rounding to 8 bits first would lose.\n\n## The pngjs API\n\nEverything pngjs exports works the same way, so you can replace\n\n```js\nconst { PNG } = require(\"pngjs\");\n```\n\nwith\n\n```js\nconst { PNG } = require(\"@jimp/pngjs\");\n```\n\n`@types/pngjs` isn't needed: the types are included.\n\n```js\n// Sync\nconst png = PNG.sync.read(buffer, { checkCRC, skipRescale, keepIndexed });\nconst file = PNG.sync.write(png, { colorType, bitDepth, filterType, ... });\n\n// Streams\nfs.createReadStream(\"in.png\")\n  .pipe(new PNG({ filterType: 4 }))\n  .on(\"parsed\", function () {\n    // this.width, this.height, this.data, this.gamma, ...\n    this.pack().pipe(fs.createWriteStream(\"out.png\"));\n  });\n\nnew PNG().parse(buffer, (error, png) => {});\n\nPNG.bitblt(src, dst, srcX, srcY, width, height, deltaX, deltaY);\nPNG.adjustGamma(png);\n```\n\nThe options, events and properties are documented in\n[pngjs's README](https://github.com/pngjs/pngjs#readme). Additions:\n\n- `colorType: 3` writes a palette, and `bitDepth` can be 1, 2 or 4 for\n  palette and grayscale output.\n- `keepIndexed: true` decodes palette images to one palette index per pixel.\n- `filterType` takes a list of filter types, as pngjs's README says it does.\n- `idatChunkSize` splits the image data into several IDAT chunks.\n- Parsed images also have `palette`, `transColor`, `iccProfile`, `physical`\n  and `text`.\n- `PNG` emits `finish` and `close` once parsed, so `stream.pipeline` works,\n  and `for await (const chunk of png.pack())` reads the packed PNG.\n\nDifferences you might notice:\n\n- Pixels made transparent by a tRNS colour keep their colour, like in libpng\n  and browsers. pngjs made them transparent black.\n- Converting colour to gray rounds the mean of R, G and B. pngjs truncated it.\n- Events are always emitted asynchronously, `metadata` too.\n- `pack()` emits the PNG as one `data` event, unless you pass a\n  `deflateFactory`.\n- Errors are always `Error` objects. pngjs sometimes emitted strings.\n- In browsers `data` is a `Uint8Array`, as there's no `Buffer`, and `PNG` is\n  an event emitter with `pipe()` rather than a Node.js stream.\n\n## Browsers\n\nIn Node.js the package compresses with the built-in `node:zlib`. Its\n`browser` export condition, which bundlers use when they build for browsers,\nswaps that for [pako](https://github.com/nodeca/pako), a port of zlib, so the\noutput is the same byte for byte. There's nothing to polyfill or configure.\n\nBundled and minified, `decode` alone is 40 KB (14 KB gzipped), and the whole\npackage is 70 KB (23 KB gzipped). pngjs's browser build is 205 KB (62 KB\ngzipped).\n\nWe picked pako over [fflate](https://github.com/101arrowz/fflate), which is\nsmaller, because fflate has no run-length (`Z_RLE`) strategy. That's the\ndefault of pngjs and Jimp, and with fflate encoding was several times slower\nand the files a little bigger.\n\n## Fixed from pngjs\n\nEvery open issue and pull request on [pngjs](https://github.com/pngjs/pngjs/issues)\nas of November 2026. Most fixes have a test named after the issue in\n[src/issues.test.ts](./src/issues.test.ts) or\n[src/issues.node.test.ts](./src/issues.node.test.ts).\n\n| Issue                                             | Problem                                            | Status                                                                              |\n| ------------------------------------------------- | -------------------------------------------------- | ----------------------------------------------------------------------------------- |\n| [#9](https://github.com/pngjs/pngjs/issues/9)     | 16-bit gamma correction off by 1                   | Fixed: `adjustGamma` works on 16-bit data                                           |\n| [#10](https://github.com/pngjs/pngjs/issues/10)   | 16-bit gamma off by 16                             | Obsolete: an old test setting, see #9                                               |\n| [#54](https://github.com/pngjs/pngjs/issues/54)   | BGRA/ARGB to PNG                                   | Usage question                                                                      |\n| [#64](https://github.com/pngjs/pngjs/issues/64)   | `pack()` isn't a real Readable                     | Improved: `for await` works. It's still a classic stream                            |\n| [#81](https://github.com/pngjs/pngjs/issues/81)   | Grayscale from RGB data                            | Usage (`inputColorType: 0`). RGB to gray now rounds                                 |\n| [#90](https://github.com/pngjs/pngjs/issues/90)   | Palette images                                     | Added: palette writing and `keepIndexed`                                            |\n| [#101](https://github.com/pngjs/pngjs/issues/101) | No `close` event, `stream.pipeline` never finishes | Fixed                                                                               |\n| [#107](https://github.com/pngjs/pngjs/issues/107) | 24/32-bit support                                  | Usage: that's 8-bit RGB/RGBA, supported                                             |\n| [#115](https://github.com/pngjs/pngjs/issues/115) | Writing metadata                                   | Added: text chunks, pHYs, gamma, sRGB, iCCP, eXIf                                   |\n| [#122](https://github.com/pngjs/pngjs/issues/122) | \"Invalid file signature\"                           | Not a bug: the files were JPEGs. The error says \"not a PNG file\"                    |\n| [#128](https://github.com/pngjs/pngjs/issues/128) | Fetch and web streams                              | `decode` takes the `ArrayBuffer` from `response.arrayBuffer()`                      |\n| [#136](https://github.com/pngjs/pngjs/issues/136) | \"incorrect data check\"                             | Fixed: a wrong zlib checksum is ignored, sync and async                             |\n| [#146](https://github.com/pngjs/pngjs/issues/146) | Colours differ from Chrome                         | Not a bug: the file has a Display P3 profile, now in `iccProfile`                   |\n| [#178](https://github.com/pngjs/pngjs/issues/178) | Custom gamma                                       | Added: `adjustGamma`'s `displayGamma`                                               |\n| [#209](https://github.com/pngjs/pngjs/issues/209) | \"Unexpected end of input\"                          | Can't reproduce: the file was cut off. Cut-off files now say so                     |\n| [#219](https://github.com/pngjs/pngjs/issues/219) | Resizing                                           | Out of scope, see [Jimp](https://github.com/jimp-dev/jimp)                          |\n| [#247](https://github.com/pngjs/pngjs/issues/247) | Streaming pixel rows                               | Not planned                                                                         |\n| [#252](https://github.com/pngjs/pngjs/issues/252) | Packing twice writes broken files                  | Fixed                                                                               |\n| [#281](https://github.com/pngjs/pngjs/issues/281) | Cropping                                           | Usage: `bitblt` into a smaller PNG                                                  |\n| [#282](https://github.com/pngjs/pngjs/issues/282) | `this` in `parsed`                                 | Usage: arrow functions                                                              |\n| [#283](https://github.com/pngjs/pngjs/issues/283) | Colour type options                                | Usage question                                                                      |\n| [#284](https://github.com/pngjs/pngjs/issues/284) | A weird issue                                      | Usage: wrong `require` path                                                         |\n| [#285](https://github.com/pngjs/pngjs/issues/285) | `filterType: 0` with transparent pixels            | Fixed in pngjs 2018, has a test                                                     |\n| [#286](https://github.com/pngjs/pngjs/issues/286) | Large images                                       | Fixed: memory is only allocated as the data proves it's needed. Tested at 6000x4000 |\n| [#287](https://github.com/pngjs/pngjs/issues/287) | `bitblt` in the README                             | Fixed: the instance method is in the types                                          |\n| [#288](https://github.com/pngjs/pngjs/issues/288) | Browser and Node.js entry points                   | Done: `browser` export condition                                                    |\n| [#295](https://github.com/pngjs/pngjs/issues/295) | Babel and the browser build                        | Gone with the browserify build                                                      |\n| [#298](https://github.com/pngjs/pngjs/issues/298) | \"read requests waiting on finished stream\"         | Fixed: a missing IEND chunk is fine if the image is complete                        |\n| [#329](https://github.com/pngjs/pngjs/issues/329) | `this.on is not a function`                        | Fixed: no zlib internals are used                                                   |\n| [#356](https://github.com/pngjs/pngjs/issues/356) | An API without streams                             | Added: `decode` and `encode`                                                        |\n| [#360](https://github.com/pngjs/pngjs/issues/360) | Writing grayscale                                  | Usage (option spelling and byte order). Grayscale writing has tests                 |\n| [#380](https://github.com/pngjs/pngjs/issues/380) | Memory leak                                        | Fixed: a `PNG` schedules nothing until it's used                                    |\n| [#381](https://github.com/pngjs/pngjs/issues/381) | File permissions in the package                    | Not applicable to this package                                                      |\n| [#382](https://github.com/pngjs/pngjs/issues/382) | Base64                                             | Usage: `PNG.sync.write(png).toString(\"base64\")`                                     |\n| [#383](https://github.com/pngjs/pngjs/issues/383) | pHYs                                               | Added, read and written                                                             |\n| [#386](https://github.com/pngjs/pngjs/issues/386) | Losing colours                                     | Like #146: the ICC profile is in `iccProfile`                                       |\n| [#389](https://github.com/pngjs/pngjs/issues/389) | Accessing the palette                              | Added: `palette`                                                                    |\n| [#390](https://github.com/pngjs/pngjs/issues/390) | IEND bytes                                         | Not a bug: they are IEND. Has a test                                                |\n| [#392](https://github.com/pngjs/pngjs/issues/392) | \"pin pngjs to v2.3.0\" on Node.js 24                | Fixed: zlib comes from the right build, no feature detection                        |\n| [#394](https://github.com/pngjs/pngjs/issues/394) | Huge allocations from a small file                 | Fixed: sizes are checked, and allocated only once the data is there                 |\n\n| Pull request                                    | Change                 | Status                                                  |\n| ----------------------------------------------- | ---------------------- | ------------------------------------------------------- |\n| [#225](https://github.com/pngjs/pngjs/pull/225) | Writing palette images | Reimplemented, with `keepIndexed`                       |\n| [#334](https://github.com/pngjs/pngjs/pull/334) | CRC cleanup            | Not needed: native `zlib.crc32` where available         |\n| [#384](https://github.com/pngjs/pngjs/pull/384) | Reading pHYs           | Reimplemented, with writing                             |\n| [#385](https://github.com/pngjs/pngjs/pull/385) | Several IDAT chunks    | Reimplemented as `idatChunkSize`                        |\n| [#387](https://github.com/pngjs/pngjs/pull/387) | Native zlib            | Reimplemented: native zlib in Node.js, pako in browsers |\n| [#395](https://github.com/pngjs/pngjs/pull/395) | Next-tick retention    | Reimplemented: no ticks until data arrives              |\n\nBugs without an issue, some found in forks of pngjs:\n\n- Async errors (like a bad filter byte) crashed the process instead of\n  emitting `error`\n- A short zlib stream returned uninitialised memory as pixels\n- Image data that was too short decoded to a black image instead of an error\n- 16-bit input ignored a `Buffer`'s offset, reading the wrong memory\n- `inputHasAlpha: false` shifted the pixels\n- `filterType` lists threw, though the README documents them\n- gAMA was floored instead of rounded on write (0.45455 became 0.45454)\n- `new PNG({ bitDepth: 16 })` allocated half the memory it needed\n- `bitblt` accepted negative coordinates\n- `PNG.sync.write` added its defaults to the options object you passed\n- Out-of-range palette indices threw (now opaque black, like libpng)\n- A CRC error in a metadata chunk failed the whole image\n- APNG files couldn't be read in Jimp, and interlaced output wasn't\n  supported\n\n## Conformance and testing\n\n- **[PngSuite](http://www.schaik.com/pngsuite/)**: all 162 valid images decode\n  to exactly the pixels libpng does, at 8 and 16 bits, and all 14 corrupt ones\n  throw an `Error`. The reference pixels come from netpbm's `pngtopam`,\n  checked against ImageMagick, see\n  [scripts/generate-pngsuite-reference.mjs](./scripts/generate-pngsuite-reference.mjs).\n  Each image also round-trips through `encode`.\n- **pngjs**: the encoder writes the same bytes as pngjs 7.0.0 for the same\n  settings, pngjs decodes what it writes, and decoded pixels match except for\n  the differences above.\n- **APNG**: frames match ffmpeg's decoder.\n- **Fuzzing**: tens of thousands of randomly broken PngSuite images, from a\n  fixed seed, must decode or throw an `Error`, within a second.\n\nEach runs with both zlib backends.\n\n## Benchmarks\n\nMedian of 7 runs on an Apple M5 with Node.js 24, from `pnpm bench`, against\npngjs 7.0.0. \"Browser\" is each package's browser build, run in Node.js.\nEncoding uses level 9 and strategy 3, which are both packages' defaults.\n\n| Image                       | Decode: pngjs | Decode: this | Browser decode: pngjs | Browser decode: this |\n| --------------------------- | ------------: | -----------: | --------------------: | -------------------: |\n| Photo, 555x680 RGBA         |        5.7 ms |       3.6 ms |               10.7 ms |               7.8 ms |\n| Dice, 800x600 RGBA          |        7.7 ms |       2.9 ms |               13.6 ms |               5.2 ms |\n| Font atlas, 4093x146        |        5.2 ms |       0.9 ms |               11.4 ms |               2.9 ms |\n| Photo tiled, 2220x2720 RGBA |      173.1 ms |     118.2 ms |              311.8 ms |             213.2 ms |\n\n| Image                       |       Encode: pngjs | Encode: this, same settings | `encode()`, smallest format | Browser encode: pngjs | Browser encode: this |\n| --------------------------- | ------------------: | --------------------------: | --------------------------: | --------------------: | -------------------: |\n| Photo, 555x680 RGBA         |   23.5 ms, 494.7 KB |           18.2 ms, 494.7 KB |           17.1 ms, 415.6 KB |               32.0 ms |              28.3 ms |\n| Dice, 800x600 RGBA          |   17.6 ms, 232.9 KB |           11.7 ms, 232.9 KB |           11.7 ms, 232.9 KB |               23.8 ms |              17.7 ms |\n| Font atlas, 4093x146        |    17.8 ms, 90.6 KB |            11.8 ms, 90.6 KB |             8.1 ms, 46.9 KB |               22.9 ms |              16.4 ms |\n| Photo tiled, 2220x2720 RGBA | 330.5 ms, 7855.8 KB |         252.8 ms, 7855.8 KB |         233.2 ms, 6598.8 KB |              473.0 ms |             403.1 ms |\n\n## License\n\nMIT. See [LICENSE](./LICENSE) for pngjs's and node-pngjs's copyright notices.\nPngSuite's images are by Willem van Schaik, see\n[test/pngsuite/PngSuite.LICENSE](./test/pngsuite/PngSuite.LICENSE).","users":{}}