{"versions":{"2.1.0":{"name":"@jimp/jpeg-js","version":"2.1.0","keywords":["jpeg","jpg","jpeg-js","decoder","encoder","codec","image"],"author":{"name":"Andrew Lisowski","email":"lisowski54@gmail.com"},"license":"BSD-3-Clause AND Apache-2.0 AND IJG","_id":"@jimp/jpeg-js@2.1.0","maintainers":[{"name":"anonymous","email":"lisowski54@gmail.com"},{"name":"anonymous","email":"oliver@nth-iteration.ie"}],"contributors":[{"name":"Eugene Ware","email":"eugene@noblesamurai.com"},{"url":"notmasteryet","name":"Yury Delendik"},{"url":"pdf.js","name":"Mozilla Foundation"},{"url":"as3corelib","name":"Adobe Systems Incorporated"},{"url":"www.bytestrom.eu","name":"Andreas Ritter"},{"name":"Michael Kelly"},{"name":"Peter Liljenberg"},{"name":"XadillaX"},{"name":"strandedcity"},{"name":"wmossman"},{"name":"Patrick Hulce"},{"name":"Ben Wiley"}],"homepage":"https://github.com/jimp-dev/jimp#readme","bugs":{"url":"https://github.com/jimp-dev/jimp/issues"},"dist":{"shasum":"204cef483c7a51a6df3867e133116c3c8ebd17d2","tarball":"http://123.232.10.234:8212/nexus/content/repositories/npm-private/@jimp/jpeg-js/-/jpeg-js-2.1.0.tgz","fileCount":225,"integrity":"sha512-mUyLUvHBoLDH7W2fYuA19JWE1RVhocufAP47dnGZKKAvyvV5dO7m8y3zkpkb7a+lP+tWQROGALDC2BcDDW/YPQ==","signatures":[{"sig":"MEUCIEwZNmPeDTu/Op54IQC3rzxsF5EfvMAzjglVrxfSSVMjAiEA81KwHxaXfeSx0jx6FFyKu0azn225YJ03Ljqu0Yzzv5A=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"sig":"MEYCIQCOp4Kldwu+u62TEQbibXOs/Lua79afm3ZEW9OfLAyJQAIhAPukba0U5VSRm0kZ519Yhe6rOhdM8Ayvx/BU/KJ20C9g","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":1689713,"size":247796},"main":"./dist/commonjs/index.js","tshy":{"exclude":["**/*.test.ts","test/**"],"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","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":"JPEG encoder and decoder in pure JavaScript, for Node.js and browsers. A maintained fork of jpeg-js.","directories":{},"sideEffects":false,"_nodeVersion":"24.15.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tshy":"~4.0.0","eslint":"^10.15.0","vitest":"^5.1.1","jpeg-js":"^0.4.4","playwright":"^1.65.1","typescript":"^7.0.2","@types/node":"^22.20.5","@vitest/browser":"^5.1.1","@jimp/config-eslint":"2.1.0","@jimp/config-typescript":"2.1.0","@vitest/browser-playwright":"^5.1.1"},"_npmOperationalInternal":{"tmp":"tmp/jpeg-js_2.1.0_1795562588568_0.2709563971469571","host":"s3://npm-registry-packages-npm-production"},"_cnpmcore_publish_time":"2026-11-24T23:23:08.699Z","publish_time":1795562588699,"_source_registry_name":"default"},"2.2.0":{"_id":"@jimp/jpeg-js@2.2.0","bugs":{"url":"https://github.com/jimp-dev/jimp/issues"},"dist":{"shasum":"79c28b23e6a4651c785e0ed7ab73638ebdafdc19","tarball":"http://123.232.10.234:8212/nexus/content/repositories/npm-private/@jimp/jpeg-js/-/jpeg-js-2.2.0.tgz","fileCount":225,"integrity":"sha512-tccJ4f4pwasdcHjxR5HoCo/Yxlwa4BuGhnIoBtFvjEMKFTXWUqrF1ory1iR7C865rh+0XfzP9y+HejZFlAd9DA==","signatures":[{"sig":"MEQCIBuPAQjJOdbhRJ1CVljGlTxtuUZ0xvduBMo0AMbRoZvGAiB1IGYYQDg1jlDLUgIPOGnj5EyP4uMOIIc8APlPfrN3fw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCsOXSx5NV6jiXUrdUan6HMAXXaLb4TXC2brN2SWVaYKAIhAMPhQeE7iYJX3X1O1BvWcbd5EeQrRCHDfkQjUiDKyPKX"}],"unpackedSize":1689713,"size":247797},"main":"./dist/commonjs/index.js","name":"@jimp/jpeg-js","tshy":{"exclude":["**/*.test.ts","test/**"],"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":"BSD-3-Clause AND Apache-2.0 AND IJG","scripts":{"dev":"tshy --watch","lint":"eslint .","test":"vitest","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":["jpeg","jpg","jpeg-js","decoder","encoder","codec","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":"JPEG encoder and decoder in pure JavaScript, for Node.js and browsers. A maintained fork of jpeg-js.","directories":{},"maintainers":[{"name":"anonymous","email":"lisowski54@gmail.com"},{"name":"anonymous","email":"oliver@nth-iteration.ie"}],"sideEffects":false,"_nodeVersion":"24.15.0","contributors":[{"name":"Eugene Ware","email":"eugene@noblesamurai.com"},{"url":"notmasteryet","name":"Yury Delendik"},{"url":"pdf.js","name":"Mozilla Foundation"},{"url":"as3corelib","name":"Adobe Systems Incorporated"},{"url":"www.bytestrom.eu","name":"Andreas Ritter"},{"name":"Michael Kelly"},{"name":"Peter Liljenberg"},{"name":"XadillaX"},{"name":"strandedcity"},{"name":"wmossman"},{"name":"Patrick Hulce"},{"name":"Ben Wiley"}],"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tshy":"~4.0.0","eslint":"^10.15.0","vitest":"^5.1.1","jpeg-js":"^0.4.4","playwright":"^1.65.1","typescript":"^7.0.2","@types/node":"^22.20.5","@vitest/browser":"^5.1.1","@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/jpeg-js_2.2.0_1795629461984_0.22304382423929692"},"_cnpmcore_publish_time":"2026-11-25T17:57:42.130Z","publish_time":1795629462130,"_source_registry_name":"default"},"0.0.0-stage":{"name":"@jimp/jpeg-js","version":"0.0.0-stage","_id":"@jimp/jpeg-js@0.0.0-stage","stub":true,"maintainers":[{"name":"anonymous","email":"lisowski54@gmail.com"}],"dist":{"shasum":"3dfc61c489915b0f92fa91aa0743084d6d0a87c3","tarball":"http://123.232.10.234:8212/nexus/content/repositories/npm-private/@jimp/jpeg-js/-/jpeg-js-0.0.0-stage.tgz","fileCount":2,"integrity":"sha512-GqBL7D67Hv6f/OX9eUsSrJ1dZqS6973CsNSX2DkAkENEfbbT5Rg72T5BwLpyocWvwl1WITa8fCnJQ+PicH93BQ==","signatures":[{"sig":"MEYCIQCEOoseD+rjqZ850fN5YfXp3XTdORKg+kg2lWBakEsTbAIhANvPXyn/Q4VHlpX07ypaMe187rfCVlGnQPBWJMLFn9uL","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":335,"size":366},"_npmUser":{"name":"anonymous","email":"lisowski54@gmail.com"},"description":"Temporary package placeholder for staged publishing","directories":{},"_cnpmcore_publish_time":"2026-11-24T23:21:01.759Z","publish_time":1795562461759,"_hasShrinkwrap":false,"_source_registry_name":"default","contributors":[]},"2.2.1":{"_id":"@jimp/jpeg-js@2.2.1","bugs":{"url":"https://github.com/jimp-dev/jimp/issues"},"dist":{"shasum":"454468793f3d2af7a2a02dfe514282ab8856285f","tarball":"http://123.232.10.234:8212/nexus/content/repositories/npm-private/@jimp/jpeg-js/-/jpeg-js-2.2.1.tgz","fileCount":225,"integrity":"sha512-vUwAzsJLioxLPLAHuWGG+bjN3VstT10WnFF1Q5pfVEw5MGBAjaLAf5sFW4beFn4cNjGWDi97R2PNqlV1iZmoaw==","signatures":[{"sig":"MEQCIA8VGdH4QKs7CuMEdhkb9TnsLn67KtPhRyRYuthWRNc6AiANBo/aKSplWxfrTxTiKDttg5UnGLZt+xOjeGXDLqAnTg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIFBGtkBVeTcKQgUmGifhpinOPvLh+d4T6P/E4mqieSj+AiEAs40Z0LtD5RZ1hJ6hqAOCOD6u2lKIGjfpvxHxp01/Qps="}],"unpackedSize":1689713,"size":247797},"main":"./dist/commonjs/index.js","name":"@jimp/jpeg-js","tshy":{"exclude":["**/*.test.ts","test/**"],"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":"BSD-3-Clause AND Apache-2.0 AND IJG","scripts":{"dev":"tshy --watch","lint":"eslint .","test":"vitest","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":["jpeg","jpg","jpeg-js","decoder","encoder","codec","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":"JPEG encoder and decoder in pure JavaScript, for Node.js and browsers. A maintained fork of jpeg-js.","directories":{},"maintainers":[{"name":"anonymous","email":"lisowski54@gmail.com"},{"name":"anonymous","email":"oliver@nth-iteration.ie"}],"sideEffects":false,"_nodeVersion":"24.15.0","contributors":[{"name":"Eugene Ware","email":"eugene@noblesamurai.com"},{"url":"notmasteryet","name":"Yury Delendik"},{"url":"pdf.js","name":"Mozilla Foundation"},{"url":"as3corelib","name":"Adobe Systems Incorporated"},{"url":"www.bytestrom.eu","name":"Andreas Ritter"},{"name":"Michael Kelly"},{"name":"Peter Liljenberg"},{"name":"XadillaX"},{"name":"strandedcity"},{"name":"wmossman"},{"name":"Patrick Hulce"},{"name":"Ben Wiley"}],"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tshy":"~4.0.0","eslint":"^10.15.0","vitest":"^5.1.1","jpeg-js":"^0.4.4","playwright":"^1.65.1","typescript":"^7.0.2","@types/node":"^22.20.5","@vitest/browser":"^5.1.1","@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/jpeg-js_2.2.1_1795814508413_0.12614592747714437"},"_cnpmcore_publish_time":"2026-11-27T21:21:48.506Z","publish_time":1795814508506,"_source_registry_name":"default"},"2.2.2":{"_id":"@jimp/jpeg-js@2.2.2","bugs":{"url":"https://github.com/jimp-dev/jimp/issues"},"dist":{"shasum":"8ae9303632b8392bdc4a8b105591c5dfb11804a0","tarball":"http://123.232.10.234:8212/nexus/content/repositories/npm-private/@jimp/jpeg-js/-/jpeg-js-2.2.2.tgz","fileCount":225,"integrity":"sha512-Or3jEUQuX4XnEDHuVXDuk3P5W2dViyuwPJHPDnj8SSGPhzPDcEzggRSOYzkXy2rac1Ahex/22YapuYRoxM6npA==","signatures":[{"sig":"MEYCIQDQDtXO+pT7/C/jVaAmVq6zhwVb3h3HbSnp+7hBN9UIPAIhALiK4j11TuuXrjwQqXLV13LHXszu9BljhAXWxk3q2ukX","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDCIdnyR+zC1bg7EpsqanRQcapTe5coqXswa1+rG1TViQIhALBRrwayZIq2hrIpjWNIjhZ/q5MhYy+cC7+Lejtfam6M"}],"unpackedSize":1689713,"size":247795},"main":"./dist/commonjs/index.js","name":"@jimp/jpeg-js","tshy":{"exclude":["**/*.test.ts","test/**"],"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":"BSD-3-Clause AND Apache-2.0 AND IJG","scripts":{"dev":"tshy --watch","lint":"eslint .","test":"vitest","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":["jpeg","jpg","jpeg-js","decoder","encoder","codec","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":"JPEG encoder and decoder in pure JavaScript, for Node.js and browsers. A maintained fork of jpeg-js.","directories":{},"maintainers":[{"name":"anonymous","email":"lisowski54@gmail.com"},{"name":"anonymous","email":"oliver@nth-iteration.ie"}],"sideEffects":false,"_nodeVersion":"24.15.0","contributors":[{"name":"Eugene Ware","email":"eugene@noblesamurai.com"},{"url":"notmasteryet","name":"Yury Delendik"},{"url":"pdf.js","name":"Mozilla Foundation"},{"url":"as3corelib","name":"Adobe Systems Incorporated"},{"url":"www.bytestrom.eu","name":"Andreas Ritter"},{"name":"Michael Kelly"},{"name":"Peter Liljenberg"},{"name":"XadillaX"},{"name":"strandedcity"},{"name":"wmossman"},{"name":"Patrick Hulce"},{"name":"Ben Wiley"}],"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tshy":"~4.0.0","eslint":"^10.15.0","vitest":"^5.1.1","jpeg-js":"^0.4.4","playwright":"^1.65.1","typescript":"^7.0.2","@types/node":"^22.20.5","@vitest/browser":"^5.1.1","@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/jpeg-js_2.2.2_1796012035837_0.4401840707586092"},"_cnpmcore_publish_time":"2026-11-30T04:13:55.936Z","publish_time":1796012035936,"_source_registry_name":"default"}},"dist-tags":{"latest":"2.2.2"},"name":"@jimp/jpeg-js","time":{"created":"2026-11-25T17:57:57.245Z","modified":"2026-11-30T04:14:05.733Z","2.1.0":"2026-11-24T23:23:08.699Z","2.2.0":"2026-11-25T17:57:42.130Z","0.0.0-stage":"2026-11-24T23:21:01.759Z","2.2.1":"2026-11-27T21:21:48.506Z","2.2.2":"2026-11-30T04:13:55.936Z"},"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/jpeg-js</h1>\n  <p>A maintained fork of jpeg-js: JPEG encoder and decoder in pure JavaScript.</p>\n</div>\n\n## Based on jpeg-js / pdf.js / as3corelib\n\nThis package is a fork of [jpeg-js](https://github.com/jpeg-js/jpeg-js) by\nEugene Ware and contributors (BSD 3-Clause). Its decoder comes from\n[jpgjs](https://github.com/notmasteryet/jpgjs) by notmasteryet, which became\nthe JPEG decoder of [pdf.js](https://github.com/mozilla/pdf.js) (Apache 2.0).\nIts encoder is the JPGEncoder of Adobe's as3corelib (BSD 3-Clause), ported to\nJavaScript by Andreas Ritter. The entropy decoding, inverse DCT, upsampling\nand colour conversion are ports of\n[libjpeg-turbo](https://github.com/libjpeg-turbo/libjpeg-turbo), so decoded\npixels match it exactly: this software is based in part on the work of the\nIndependent JPEG Group. See [LICENSE](./LICENSE), [NOTICE](./NOTICE) and\n[README.ijg](./README.ijg).\n\n## Why\n\njpeg-js hasn't had a release since 2022. It crashes with `TypeError`s on\nmalformed files, decodes colours a few levels off from other software,\nallocates hundreds of megabytes for an ordinary photo, and its encoder writes\nlarge files. @jimp/jpeg-js keeps its API and fixes all of that:\n\n- **Exact:** decoded pixels are identical to libjpeg-turbo's (what Chrome,\n  Firefox, Pillow, sharp and ImageMagick use) for every JPEG in a corpus of\n  158, from baseline to progressive, every chroma subsampling, CMYK, YCCK,\n  12-bit and arithmetic-coded.\n- **Robust:** malformed input only ever throws a `JpegError`, never hangs, and\n  can't make the decoder allocate more than `maxMemoryUsageInMB`. The decoder\n  is fuzzed in its tests.\n- **Small files:** 4:2:0 chroma subsampling, optimized Huffman tables and\n  progressive encoding make files about 20% smaller than jpeg-js's at the\n  same SSIM.\n- **Fast and lean:** about twice as fast as jpeg-js, with a third of its peak\n  memory when decoding.\n- **Anywhere:** ESM and CommonJS, TypeScript types, and no dependencies. It\n  works in browsers without a `Buffer` polyfill.\n\n## Install\n\n```sh\nnpm install @jimp/jpeg-js\n```\n\n## Usage\n\n```ts\nimport { readFileSync, writeFileSync } from \"node:fs\";\nimport { decodeJpeg, encodeJpeg } from \"@jimp/jpeg-js\";\n\n// { width, height, data: Uint8Array of RGBA pixels, exifBuffer?, comments? }\nconst image = decodeJpeg(readFileSync(\"photo.jpg\"));\n\n// RGBA (4 bytes per pixel), RGB (3) or greyscale (1) pixels\nconst jpeg = encodeJpeg(image, { quality: 80, progressive: true });\n\nwriteFileSync(\"small.jpg\", jpeg);\n```\n\n### As a drop-in replacement for jpeg-js\n\n`decode` and `encode` take the same arguments as jpeg-js's and return the\nsame objects, with `Buffer`s in Node.js:\n\n```js\nconst jpeg = require(\"@jimp/jpeg-js\");\n\nconst raw = jpeg.decode(readFileSync(\"photo.jpg\"), { useTArray: true });\nconst { data } = jpeg.encode(raw, 50);\n```\n\nPixels decode to the same as libjpeg-turbo rather than jpeg-js's, which were\na few levels off, and the encoder writes smaller files: see\n[Differences from jpeg-js](#differences-from-jpeg-js).\n\n## API\n\n### `decodeJpeg(data, options?)`\n\nDecodes a JPEG from a `Uint8Array` (or `Buffer`), `ArrayBuffer`, other typed\narray, `DataView` or array of bytes. Returns\n`{ width, height, data, exifBuffer?, comments? }`, where `data` is a\n`Uint8Array` of RGBA pixels, row by row.\n\n| Option               | Default | Description                                                                                                                                                                                   |\n| -------------------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `formatAsRGBA`       | `true`  | RGBA pixels (alpha is always 255); `false` for RGB.                                                                                                                                           |\n| `colorTransform`     | auto    | Whether the data is YCbCr (or YCCK) to convert to RGB (or CMYK). By default it's picked like libjpeg does, from the JFIF and Adobe markers and the component IDs.                             |\n| `tolerantDecoding`   | `true`  | Recover from corrupt data like libjpeg does: junk between segments, a marker that lost its 0xFF, wrong segment lengths, bad Huffman codes, misplaced restart markers. `false` throws instead. |\n| `allowTruncated`     | `false` | Decode a JPEG whose image data was cut off, with the rest grey (or unrefined, if progressive), like browsers show it. Otherwise it throws. A missing EOI marker is always fine.               |\n| `maxResolutionInMP`  | `100`   | Throw a `JpegLimitError` for larger images, in megapixels.                                                                                                                                    |\n| `maxMemoryUsageInMB` | `512`   | Throw a `JpegLimitError` if decoding would take more memory than this, including the pixels.                                                                                                  |\n| `tables`             |         | The DQT and DHT tables of an \"abbreviated\" JPEG that leaves them out (e.g. a TIFF's JPEGTables), as a JPEG of only SOI, tables and EOI.                                                       |\n\nThe decoder doesn't rotate images by their EXIF orientation; read it from\n`exifBuffer` if you need it.\n\n### `encodeJpeg(image, options?)`\n\nEncodes `{ width, height, data }`, where `data` is RGBA, RGB or greyscale\npixels (told apart by its length), and returns a `Uint8Array`. Greyscale\ninput makes a one-component JPEG. Throws a `TypeError` or `RangeError` for\ninput that can't be encoded.\n\n| Option              | Default                                    | Description                                                                                                                                         |\n| ------------------- | ------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `quality`           | `75`                                       | 1 to 100. Scales the quantization tables of the JPEG standard like libjpeg.                                                                         |\n| `chromaSubsampling` | `\"4:2:0\"` below quality 90, else `\"4:4:4\"` | `\"4:4:4\"`, `\"4:2:2\"` or `\"4:2:0\"`: how much to reduce the resolution of the colour channels.                                                        |\n| `optimizeHuffman`   | `true`                                     | Huffman tables built for the image instead of the standard's examples, like libjpeg's `optimize_coding`: 5-15% smaller, with the same pixels.       |\n| `progressive`       | `false`                                    | A progressive JPEG with libjpeg's default scans, shown at low quality first while it loads. A few percent smaller, but slower to encode and decode. |\n| `comments`          |                                            | Strings to write in COM segments.                                                                                                                   |\n| `exif`              |                                            | EXIF data for an APP1 segment. \"Exif\\0\" is added if it doesn't start with \"Exif\", so a decoded `exifBuffer` can be passed back.                     |\n\nEvery file has a JFIF header.\n\n### `decode(data, options?)` and `encode(image, quality?)`\n\njpeg-js's API. `decode` takes the options of `decodeJpeg` plus `useTArray`,\nand returns the pixels as a `Buffer` unless `useTArray` is `true` (or there's\nno `Buffer`, as in browsers). `encode` takes `comments` and `exifBuffer` on\nthe image, a quality that defaults to 50, and returns\n`{ data, width, height }`. The default export is `{ decode, encode }`.\n\n### Errors\n\nEverything the decoder throws extends `JpegError`:\n\n- `JpegFormatError`: not a JPEG, or corrupt or truncated beyond recovery;\n- `JpegUnsupportedError`: a lossless or hierarchical JPEG, or sample\n  precision other than 8 or 12 bits;\n- `JpegLimitError`: over `maxResolutionInMP` or `maxMemoryUsageInMB`. The\n  messages are jpeg-js's, e.g. `maxResolutionInMP limit exceeded by 3MP`.\n\n## Differences from jpeg-js\n\n### Decoding\n\nThe decoder is rebuilt on pdf.js's marker parser, with libjpeg-turbo's\nHuffman, arithmetic and progressive decoding, islow IDCT, block smoothing,\n\"fancy\" upsampling and colour conversion. jpeg-js upsampled chroma by\nrepeating pixels and used a less exact IDCT, so its colours were up to tens of\nlevels off along edges. Sequential JPEGs are decoded a row of MCUs at a time\ninto one buffer per component, where jpeg-js allocated a typed array for each\n8x8 block.\n\n### Encoding\n\nThe encoder subsamples chroma, optimizes its Huffman tables, can write\nprogressive JPEGs, accepts RGB and greyscale input, repeats the last row and\ncolumn of the image to fill edge blocks, and writes into a `Uint8Array`\ninstead of an array of numbers.\n\n### jpeg-js issues\n\nEvery open issue on jpeg-js as of November 2026:\n\n| Issue                                                    | Status                                                                                                                          |\n| -------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- |\n| [#3](https://github.com/jpeg-js/jpeg-js/issues/3)        | Done: `encodeJpeg` takes RGBA, RGB or greyscale pixels.                                                                         |\n| [#12](https://github.com/jpeg-js/jpeg-js/issues/12)      | Done: `progressive: true`.                                                                                                      |\n| [#17](https://github.com/jpeg-js/jpeg-js/issues/17)      | Fixed: fancy upsampling, identical to libjpeg-turbo.                                                                            |\n| [#21](https://github.com/jpeg-js/jpeg-js/issues/21)      | Fixed: restart intervals that end part-way through a scan, extra restart markers and resynchronization on corrupt data.         |\n| [#27](https://github.com/jpeg-js/jpeg-js/issues/27)      | Not applicable (project governance).                                                                                            |\n| [#30](https://github.com/jpeg-js/jpeg-js/issues/30)      | Done: the parser is pdf.js's current one, with libjpeg-turbo's decoding pipeline.                                               |\n| [#31](https://github.com/jpeg-js/jpeg-js/issues/31)      | Done: `chromaSubsampling`, 4:2:0 by default below quality 90.                                                                   |\n| [#37](https://github.com/jpeg-js/jpeg-js/issues/37)      | Fixed: the encoder validates its input, and the decoder rejects a file too small for the image it claims before allocating it.  |\n| [#42](https://github.com/jpeg-js/jpeg-js/issues/42)      | Done: `JpegError` and its subclasses.                                                                                           |\n| [#43](https://github.com/jpeg-js/jpeg-js/issues/43)      | Partly: JPEG-in-TIFF works with `tables` (the JPEGTables tag). Old-style JPEG (OJPEG) isn't supported.                          |\n| [#63](https://github.com/jpeg-js/jpeg-js/issues/63)      | Fixed: SOS before SOF throws a `JpegFormatError`.                                                                               |\n| [#70](https://github.com/jpeg-js/jpeg-js/issues/70)      | Partly: decoding takes about a third of the memory. There's no option to decode into a buffer you provide.                      |\n| [#77](https://github.com/jpeg-js/jpeg-js/issues/77)      | Fixed: decoded pixels are identical to libjpeg-turbo's.                                                                         |\n| [#81](https://github.com/jpeg-js/jpeg-js/issues/81)      | Fixed: a progressive JPEG cut off between scans decodes, smoothed like libjpeg-turbo does.                                      |\n| [#83](https://github.com/jpeg-js/jpeg-js/issues/83)      | Done: ESM, CommonJS and browser builds, with types.                                                                             |\n| [#85](https://github.com/jpeg-js/jpeg-js/issues/85)      | Done: the `tables` option.                                                                                                      |\n| [#94](https://github.com/jpeg-js/jpeg-js/issues/94)      | Fixed: SOS before SOF throws a `JpegFormatError`.                                                                               |\n| [#95](https://github.com/jpeg-js/jpeg-js/issues/95)      | Fixed: an unknown component in SOS throws a `JpegFormatError`.                                                                  |\n| [#96](https://github.com/jpeg-js/jpeg-js/issues/96)      | Fixed: a missing quantization table throws a `JpegFormatError`.                                                                 |\n| [#97](https://github.com/jpeg-js/jpeg-js/issues/97)      | Fixed: a missing Huffman table throws a `JpegFormatError` (in sequential JPEGs, the standard tables are used, like libjpeg).    |\n| [#107](https://github.com/jpeg-js/jpeg-js/issues/107)    | Fixed in jpeg-js 0.4.4; sampling factors are validated here too.                                                                |\n| [#109](https://github.com/jpeg-js/jpeg-js/issues/109)    | Couldn't reproduce: the attached file decodes. Junk where a marker should be is skipped.                                        |\n| [#112](https://github.com/jpeg-js/jpeg-js/issues/112)    | Fixed: throws a `JpegFormatError`.                                                                                              |\n| [#113](https://github.com/jpeg-js/jpeg-js/issues/113)    | Not a codec bug: EXIF orientation isn't applied by the decoder. Jimp applies it, once. Pass `exifBuffer` back to keep it.       |\n| [#115](https://github.com/jpeg-js/jpeg-js/issues/115)    | Fixed: the colour space is picked like libjpeg, so an Adobe transform of 0 means RGB. An explicit `colorTransform` always wins. |\n| [#117](https://github.com/jpeg-js/jpeg-js/issues/117)    | Fixed: extra restart markers are skipped.                                                                                       |\n| [Jimp #153](https://github.com/jimp-dev/jimp/issues/153) | Fixed: decoding a 21 MP photo peaks at 336 MB instead of 957 MB, and a 3.3 MP one at 89 MB instead of 231 MB.                   |\n\n## Conformance\n\nThe tests decode a corpus of 159 JPEGs and compare them with libjpeg-turbo\n3.2's djpeg, with its default islow IDCT and fancy upsampling (the references\nwere made with SIMD disabled; its NEON build gives the same output for every\nfile): libjpeg-turbo's test images, jpeg-js's fixtures, JPEGs from\npdf.js's test files, the images attached to jpeg-js issues, and generated ones\ncovering 4:4:4, 4:2:2, 4:2:0, 4:4:0, 4:1:1, 4:1:0 and mixed sampling,\nbaseline, progressive and arithmetic coding, restart intervals, greyscale,\nRGB, CMYK, YCCK, 12-bit samples, 16-bit quantization tables, non-interleaved\nscans, sizes from 1x1 that don't fill whole MCUs, and progressive JPEGs cut\noff after a scan. The tolerance is 0: all 158 are identical to djpeg's output,\nexcept for a lossless JPEG, which is rejected with a `JpegUnsupportedError`.\nSee\n[test/corpus](./test/corpus/README.md).\n\n## Benchmarks\n\nOn an Apple Silicon Mac with Node.js 24, against jpeg-js 0.4.4, with\n`bench/speed.mjs` and `bench/quality.mjs` (see [bench/](./bench/README.md)).\nTimes are the median of 3 to 5 runs; memory is the peak resident set size\nminus that of an idle Node.js process. The photos are from Jimp's tests; the\n21 MP one is a 3x enlargement of the 2376x1408 one.\n\n### Decoding\n\n| Image                         | jpeg-js        | @jimp/jpeg-js  |\n| ----------------------------- | -------------- | -------------- |\n| 640x426, 4:4:4                | 10 ms, 65 MB   | 3.3 ms, 27 MB  |\n| 2376x1408, 4:2:0              | 57 ms, 231 MB  | 26 ms, 89 MB   |\n| 2376x1408, 4:2:0, progressive | 70 ms, 231 MB  | 46 ms, 112 MB  |\n| 10000x783, 4:4:4              | 379 ms, 468 MB | 210 ms, 183 MB |\n| 7128x4224 (21 MP), 4:2:0      | 421 ms, 957 MB | 225 ms, 336 MB |\n\n### Encoding\n\nEncoding the decoded image at quality 75 and 100, with the default options\n(memory includes decoding the input):\n\n| Image             | jpeg-js, q75            | @jimp/jpeg-js, q75      | jpeg-js, q100            | @jimp/jpeg-js, q100     |\n| ----------------- | ----------------------- | ----------------------- | ------------------------ | ----------------------- |\n| 640x426           | 15 ms, 113 MB, 52 KB    | 4 ms, 24 MB, 36 KB      | 17 ms, 141 MB, 165 KB    | 7 ms, 29 MB, 143 KB     |\n| 2376x1408         | 59 ms, 168 MB, 246 KB   | 36 ms, 44 MB, 189 KB    | 78 ms, 234 MB, 892 KB    | 57 ms, 66 MB, 732 KB    |\n| 10000x783         | 259 ms, 261 MB, 1749 KB | 121 ms, 113 MB, 1440 KB | 587 ms, 580 MB, 10697 KB | 332 ms, 199 MB, 9790 KB |\n| 7128x4224 (21 MP) | 440 ms, 344 MB, 1338 KB | 328 ms, 195 MB, 817 KB  | 578 ms, 549 MB, 5048 KB  | 421 ms, 251 MB, 4144 KB |\n\n### File size at equal quality\n\nNine lossless photos (seven from the Kodak set, and two from Jimp's tests)\nwere encoded by both, decoded with libjpeg-turbo, and compared with the\noriginal. For each quality of jpeg-js, the table gives how much smaller\n@jimp/jpeg-js's file is at the same SSIM (on luma) or PSNR (on RGB),\ninterpolated between its own qualities. 4:2:0 subsampling costs little SSIM\nbut some PSNR, which is why the two differ below quality 90.\n\n| jpeg-js quality | Same SSIM | Same SSIM, progressive | Same PSNR | Same PSNR, progressive |\n| --------------- | --------- | ---------------------- | --------- | ---------------------- |\n| 50              | -20.4%    | -20.6%                 | -8.8%     | -9.8%                  |\n| 75              | -18.5%    | -20.4%                 | -3.9%     | -7.0%                  |\n| 85              | -18.6%    | -21.7%                 | -4.5%     | -8.2%                  |\n| 90              | -3.6%     | -7.2%                  | -3.1%     | -6.8%                  |\n| 95              | -4.6%     | -9.1%                  | -4.9%     | -9.4%                  |\n| 100             |           |                        | -12.2%    | -16.4%                 |\n\nAt the same quality setting, quality 100 files are 11% smaller (3.5 MB\ninstead of 4.0 MB for the nine) with the same PSNR and SSIM.\n\n## License\n\nBSD 3-Clause AND Apache 2.0 AND IJG: see [LICENSE](./LICENSE) for which\nfiles are under which license.","users":{}}