{"_id":"@squoosh/lib","_rev":"245122","name":"@squoosh/lib","description":"A Node library for Squoosh","dist-tags":{"latest":"0.5.3","next":"0.2.0-0"},"maintainers":[{"name":"developit","email":""},{"name":"jaffathecake","email":""}],"time":{"modified":"2023-03-27T06:46:48.000Z","created":"2021-05-19T11:17:49.201Z","0.5.3":"2023-01-03T14:49:25.733Z","0.5.2":"2023-01-03T13:53:37.585Z","0.5.1":"2023-01-03T13:50:25.827Z","0.4.1":"2022-02-16T16:24:14.580Z","0.4.0":"2021-07-21T16:16:28.971Z","0.3.1":"2021-06-16T16:11:33.299Z","0.2.3":"2021-05-25T10:50:26.495Z","0.2.2":"2021-05-24T22:59:02.242Z","0.2.1":"2021-05-19T11:29:49.075Z","0.2.0":"2021-05-19T11:21:51.896Z","0.2.0-0":"2021-05-19T11:17:49.201Z"},"users":{},"author":{"name":"Google Chrome Developers","email":"chromium-dev@google.com"},"repository":{"type":"git","url":"git+https://github.com/GoogleChromeLabs/squoosh.git"},"versions":{"0.5.3":{"name":"@squoosh/lib","version":"0.5.3","description":"A Node library for Squoosh","public":true,"main":"./build/index.js","types":"./build/index.d.ts","scripts":{"build":"rollup -c && node lib/move-d-ts.js"},"keywords":[],"author":{"name":"Google Chrome Developers","email":"chromium-dev@google.com"},"homepage":"https://github.com/GoogleChromeLabs/squoosh","repository":{"type":"git","url":"git+https://github.com/GoogleChromeLabs/squoosh.git"},"license":"Apache-2.0","engines":{"node":" ^12.5.0 || ^14.0.0 || ^16.0.0 "},"dependencies":{"wasm-feature-detect":"^1.2.11","web-streams-polyfill":"^3.0.3"},"devDependencies":{"@babel/core":"^7.14.0","@babel/preset-env":"^7.14.0","@rollup/plugin-babel":"^5.3.0","@rollup/plugin-commonjs":"^18.0.0","@rollup/plugin-node-resolve":"^11.2.1","@types/node":"^15.6.1","rollup":"^2.46.0","rollup-plugin-terser":"^7.0.2","typescript":"^4.1.3","which":"^2.0.2"},"gitHead":"918c596cba36a46ff3d7aa8ffd69580bd22528e2","bugs":{"url":"https://github.com/GoogleChromeLabs/squoosh/issues"},"_id":"@squoosh/lib@0.5.3","_nodeVersion":"18.12.1","_npmVersion":"8.19.2","dist":{"shasum":"4ecfca5657db5fbdf6c20e85c2729ebce523ddb6","size":4217464,"noattachment":false,"key":"/@squoosh/lib/-/@squoosh/lib-0.5.3.tgz","tarball":"http://name.csiicloud.com:7001/@squoosh/lib/download/@squoosh/lib-0.5.3.tgz"},"_npmUser":{"name":"jaffathecake","email":"jaffathecake@gmail.com"},"directories":{},"maintainers":[{"name":"developit","email":""},{"name":"jaffathecake","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/lib_0.5.3_1672757365464_0.5585422120926253"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2023-01-03T14:50:26.203Z","publish_time":1672757365733,"_cnpm_publish_time":1672757365733},"0.5.2":{"name":"@squoosh/lib","version":"0.5.2","description":"A Node library for Squoosh","public":true,"main":"./build/index.js","types":"./build/index.d.ts","scripts":{"build":"rollup -c && node lib/move-d-ts.js"},"keywords":[],"author":{"name":"Google Chrome Developers","email":"chromium-dev@google.com"},"homepage":"https://github.com/GoogleChromeLabs/squoosh","repository":{"type":"git","url":"git+https://github.com/GoogleChromeLabs/squoosh.git"},"license":"Apache-2.0","engines":{"node":" ^12.5.0 || ^14.0.0 || ^16.0.0 "},"dependencies":{"wasm-feature-detect":"^1.2.11","web-streams-polyfill":"^3.0.3"},"devDependencies":{"@babel/core":"^7.14.0","@babel/preset-env":"^7.14.0","@rollup/plugin-babel":"^5.3.0","@rollup/plugin-commonjs":"^18.0.0","@rollup/plugin-node-resolve":"^11.2.1","@types/node":"^15.6.1","rollup":"^2.46.0","rollup-plugin-terser":"^7.0.2","typescript":"^4.1.3","which":"^2.0.2"},"gitHead":"42594277fd3d1f31b60103eb05cc8df62a82fb86","bugs":{"url":"https://github.com/GoogleChromeLabs/squoosh/issues"},"_id":"@squoosh/lib@0.5.2","_nodeVersion":"18.12.1","_npmVersion":"8.19.2","dist":{"shasum":"27f5acb24e5622fb9823b30b93ebb9f05a65b326","size":3236,"noattachment":false,"key":"/@squoosh/lib/-/@squoosh/lib-0.5.2.tgz","tarball":"http://name.csiicloud.com:7001/@squoosh/lib/download/@squoosh/lib-0.5.2.tgz"},"_npmUser":{"name":"jaffathecake","email":"jaffathecake@gmail.com"},"directories":{},"maintainers":[{"name":"developit","email":""},{"name":"jaffathecake","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/lib_0.5.2_1672754017436_0.6403854448276174"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2023-01-03T13:53:55.537Z","publish_time":1672754017585,"_cnpm_publish_time":1672754017585},"0.5.1":{"name":"@squoosh/lib","version":"0.5.1","description":"A Node library for Squoosh","public":true,"main":"./build/index.js","types":"./build/index.d.ts","scripts":{"build":"rollup -c && node lib/move-d-ts.js"},"keywords":[],"author":{"name":"Google Chrome Developers","email":"chromium-dev@google.com"},"homepage":"https://github.com/GoogleChromeLabs/squoosh","repository":{"type":"git","url":"git+https://github.com/GoogleChromeLabs/squoosh.git"},"license":"Apache-2.0","engines":{"node":" ^12.5.0 || ^14.0.0 || ^16.0.0 "},"dependencies":{"wasm-feature-detect":"^1.2.11","web-streams-polyfill":"^3.0.3"},"devDependencies":{"@babel/core":"^7.14.0","@babel/preset-env":"^7.14.0","@rollup/plugin-babel":"^5.3.0","@rollup/plugin-commonjs":"^18.0.0","@rollup/plugin-node-resolve":"^11.2.1","@types/node":"^15.6.1","rollup":"^2.46.0","rollup-plugin-terser":"^7.0.2","typescript":"^4.1.3","which":"^2.0.2"},"gitHead":"42594277fd3d1f31b60103eb05cc8df62a82fb86","bugs":{"url":"https://github.com/GoogleChromeLabs/squoosh/issues"},"_id":"@squoosh/lib@0.5.1","_nodeVersion":"18.12.1","_npmVersion":"8.19.2","dist":{"shasum":"95d18cde15beb7b94bdafaa34007bc9912abc93b","size":3227,"noattachment":false,"key":"/@squoosh/lib/-/@squoosh/lib-0.5.1.tgz","tarball":"http://name.csiicloud.com:7001/@squoosh/lib/download/@squoosh/lib-0.5.1.tgz"},"_npmUser":{"name":"jaffathecake","email":"jaffathecake@gmail.com"},"directories":{},"maintainers":[{"name":"developit","email":""},{"name":"jaffathecake","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/lib_0.5.1_1672753825669_0.2779168568389374"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2023-01-03T13:50:37.938Z","publish_time":1672753825827,"_cnpm_publish_time":1672753825827},"0.4.1":{"name":"@squoosh/lib","version":"0.4.1","description":"A Node library for Squoosh","public":true,"main":"./build/index.js","types":"./build/index.d.ts","scripts":{"build":"rollup -c && node lib/move-d-ts.js"},"keywords":[],"author":{"name":"Google Chrome Developers","email":"chromium-dev@google.com"},"homepage":"https://github.com/GoogleChromeLabs/squoosh","repository":{"type":"git","url":"git+https://github.com/GoogleChromeLabs/squoosh.git"},"license":"Apache-2.0","engines":{"node":" ^12.5.0 || ^14.0.0 || ^16.0.0 "},"dependencies":{"wasm-feature-detect":"^1.2.11","web-streams-polyfill":"^3.0.3"},"devDependencies":{"@babel/core":"^7.14.0","@babel/preset-env":"^7.14.0","@rollup/plugin-babel":"^5.3.0","@rollup/plugin-commonjs":"^18.0.0","@rollup/plugin-node-resolve":"^11.2.1","@types/node":"^15.6.1","rollup":"^2.46.0","rollup-plugin-terser":"^7.0.2","typescript":"^4.1.3","which":"^2.0.2"},"bugs":{"url":"https://github.com/GoogleChromeLabs/squoosh/issues"},"_id":"@squoosh/lib@0.4.1","_nodeVersion":"14.15.1","_npmVersion":"6.14.8","dist":{"shasum":"c0e30deb29dbe96728a581d2ace883c560496cc5","size":4224157,"noattachment":false,"key":"/@squoosh/lib/-/@squoosh/lib-0.4.1.tgz","tarball":"http://name.csiicloud.com:7001/@squoosh/lib/download/@squoosh/lib-0.4.1.tgz"},"_npmUser":{"name":"jaffathecake","email":"jaffathecake@gmail.com"},"directories":{},"maintainers":[{"name":"developit","email":""},{"name":"jaffathecake","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/lib_0.4.1_1645028654249_0.7981759925959222"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2022-02-16T16:24:23.514Z","deprecated":"This version has bugs and other unintended breaking changes","publish_time":1645028654580,"_cnpm_publish_time":1645028654580},"0.4.0":{"name":"@squoosh/lib","version":"0.4.0","description":"A Node library for Squoosh","public":true,"main":"./build/index.js","scripts":{"build":"rollup -c"},"keywords":[],"author":{"name":"Google Chrome Developers","email":"chromium-dev@google.com"},"homepage":"https://github.com/GoogleChromeLabs/squoosh","repository":{"type":"git","url":"git+https://github.com/GoogleChromeLabs/squoosh.git"},"license":"Apache-2.0","engines":{"node":" ^12.5.0 || ^14.0.0 || ^16.0.0 "},"dependencies":{"wasm-feature-detect":"^1.2.11","web-streams-polyfill":"^3.0.3"},"devDependencies":{"@babel/core":"^7.14.0","@babel/preset-env":"^7.14.0","@rollup/plugin-babel":"^5.3.0","@rollup/plugin-commonjs":"^18.0.0","@rollup/plugin-node-resolve":"^11.2.1","@types/node":"^15.6.1","rollup":"^2.46.0","rollup-plugin-terser":"^7.0.2","typescript":"^4.1.3","which":"^2.0.2"},"bugs":{"url":"https://github.com/GoogleChromeLabs/squoosh/issues"},"_id":"@squoosh/lib@0.4.0","_nodeVersion":"16.4.0","_npmVersion":"7.18.1","dist":{"shasum":"31d18cb082c69e404589e2e281414d10f91e1668","size":4133819,"noattachment":false,"key":"/@squoosh/lib/-/@squoosh/lib-0.4.0.tgz","tarball":"http://name.csiicloud.com:7001/@squoosh/lib/download/@squoosh/lib-0.4.0.tgz"},"_npmUser":{"name":"surma","email":"surma@surma.link"},"directories":{},"maintainers":[{"name":"developit","email":""},{"name":"jaffathecake","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/lib_0.4.0_1626884188744_0.72540142945028"},"_hasShrinkwrap":false,"publish_time":1626884188971,"_cnpm_publish_time":1626884188971,"_cnpmcore_publish_time":"2021-12-16T13:39:09.360Z"},"0.3.1":{"name":"@squoosh/lib","version":"0.3.1","description":"A Node library for Squoosh","public":true,"main":"./build/index.js","scripts":{"build":"rollup -c"},"keywords":[],"author":{"name":"Google Chrome Developers","email":"chromium-dev@google.com"},"license":"Apache-2.0","dependencies":{"web-streams-polyfill":"^3.0.3"},"devDependencies":{"@babel/core":"^7.14.0","@babel/preset-env":"^7.14.0","@rollup/plugin-babel":"^5.3.0","@rollup/plugin-commonjs":"^18.0.0","@rollup/plugin-node-resolve":"^11.2.1","@types/node":"^15.6.1","rollup":"^2.46.0","rollup-plugin-terser":"^7.0.2","typescript":"^4.1.3","which":"^2.0.2"},"_id":"@squoosh/lib@0.3.1","_nodeVersion":"16.1.0","_npmVersion":"7.11.2","dist":{"shasum":"de022198f82837086c8e4e91b892dcfbbb420e17","size":3207516,"noattachment":false,"key":"/@squoosh/lib/-/@squoosh/lib-0.3.1.tgz","tarball":"http://name.csiicloud.com:7001/@squoosh/lib/download/@squoosh/lib-0.3.1.tgz"},"_npmUser":{"name":"surma","email":"surma@surma.link"},"directories":{},"maintainers":[{"name":"developit","email":""},{"name":"jaffathecake","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/lib_0.3.1_1623859892990_0.608747385096823"},"_hasShrinkwrap":false,"publish_time":1623859893299,"_cnpm_publish_time":1623859893299,"_cnpmcore_publish_time":"2021-12-16T13:39:15.613Z"},"0.2.3":{"name":"@squoosh/lib","version":"0.2.3","description":"A Node library for Squoosh","public":true,"main":"/build/index.js","scripts":{"build":"rollup -c"},"keywords":[],"author":{"name":"Google Chrome Developers","email":"chromium-dev@google.com"},"license":"Apache-2.0","dependencies":{"web-streams-polyfill":"^3.0.3"},"devDependencies":{"@babel/core":"^7.14.0","@babel/preset-env":"^7.14.0","@rollup/plugin-babel":"^5.3.0","@rollup/plugin-commonjs":"^18.0.0","@rollup/plugin-node-resolve":"^11.2.1","rollup":"^2.46.0","rollup-plugin-terser":"^7.0.2"},"_id":"@squoosh/lib@0.2.3","_nodeVersion":"14.17.0","_npmVersion":"6.14.13","dist":{"shasum":"d3469d73429c6610dc470054ccfed4d239b69d21","size":2933498,"noattachment":false,"key":"/@squoosh/lib/-/@squoosh/lib-0.2.3.tgz","tarball":"http://name.csiicloud.com:7001/@squoosh/lib/download/@squoosh/lib-0.2.3.tgz"},"_npmUser":{"name":"surma","email":"surma@surma.link"},"directories":{},"maintainers":[{"name":"developit","email":""},{"name":"jaffathecake","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/lib_0.2.3_1621939826252_0.624285359952987"},"_hasShrinkwrap":false,"publish_time":1621939826495,"_cnpm_publish_time":1621939826495,"_cnpmcore_publish_time":"2021-12-16T13:39:21.068Z"},"0.2.2":{"name":"@squoosh/lib","version":"0.2.2","description":"A Node library for Squoosh","public":true,"main":"/build/index.js","scripts":{"build":"rollup -c"},"keywords":[],"author":{"name":"Google Chrome Developers","email":"chromium-dev@google.com"},"license":"Apache-2.0","dependencies":{"web-streams-polyfill":"^3.0.3"},"devDependencies":{"@babel/core":"^7.14.0","@babel/preset-env":"^7.14.0","@rollup/plugin-babel":"^5.3.0","@rollup/plugin-commonjs":"^18.0.0","@rollup/plugin-node-resolve":"^11.2.1","rollup":"^2.46.0","rollup-plugin-terser":"^7.0.2"},"_id":"@squoosh/lib@0.2.2","_nodeVersion":"14.17.0","_npmVersion":"6.14.13","dist":{"shasum":"ccf92d82351c28f9e24541b79520001fbf78b161","size":2933315,"noattachment":false,"key":"/@squoosh/lib/-/@squoosh/lib-0.2.2.tgz","tarball":"http://name.csiicloud.com:7001/@squoosh/lib/download/@squoosh/lib-0.2.2.tgz"},"_npmUser":{"name":"surma","email":"surma@surma.link"},"directories":{},"maintainers":[{"name":"developit","email":""},{"name":"jaffathecake","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/lib_0.2.2_1621897142012_0.7564463309421772"},"_hasShrinkwrap":false,"publish_time":1621897142242,"_cnpm_publish_time":1621897142242,"_cnpmcore_publish_time":"2021-12-16T13:39:25.877Z"},"0.2.1":{"name":"@squoosh/lib","version":"0.2.1","description":"A Node library for Squoosh","public":true,"main":"/build/index.js","scripts":{"build":"rollup -c"},"keywords":[],"author":{"name":"Google Chrome Developers","email":"chromium-dev@google.com"},"license":"Apache-2.0","dependencies":{"web-streams-polyfill":"^3.0.3"},"devDependencies":{"@babel/core":"^7.14.0","@babel/preset-env":"^7.14.0","@rollup/plugin-babel":"^5.3.0","@rollup/plugin-commonjs":"^18.0.0","@rollup/plugin-node-resolve":"^11.2.1","rollup":"^2.46.0","rollup-plugin-terser":"^7.0.2"},"_id":"@squoosh/lib@0.2.1","_nodeVersion":"14.17.0","_npmVersion":"6.14.13","dist":{"shasum":"40aaf0ee68b895d2198d51f5bb5d27e95e5ed304","size":4857735,"noattachment":false,"key":"/@squoosh/lib/-/@squoosh/lib-0.2.1.tgz","tarball":"http://name.csiicloud.com:7001/@squoosh/lib/download/@squoosh/lib-0.2.1.tgz"},"_npmUser":{"name":"surma","email":"surma@surma.link"},"directories":{},"maintainers":[{"name":"developit","email":""},{"name":"jaffathecake","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/lib_0.2.1_1621423788753_0.7152307290674906"},"_hasShrinkwrap":false,"publish_time":1621423789075,"_cnpm_publish_time":1621423789075,"_cnpmcore_publish_time":"2021-12-16T13:39:37.834Z"},"0.2.0":{"name":"@squoosh/lib","version":"0.2.0","description":"A Node library for Squoosh","public":true,"main":"/build/index.js","scripts":{"build":"rollup -c"},"keywords":[],"author":{"name":"Google Chrome Developers","email":"chromium-dev@google.com"},"license":"Apache-2.0","dependencies":{"web-streams-polyfill":"^3.0.3"},"devDependencies":{"@babel/core":"^7.14.0","@babel/preset-env":"^7.14.0","@rollup/plugin-babel":"^5.3.0","@rollup/plugin-commonjs":"^18.0.0","@rollup/plugin-node-resolve":"^11.2.1","rollup":"^2.46.0","rollup-plugin-terser":"^7.0.2"},"_id":"@squoosh/lib@0.2.0","_nodeVersion":"16.1.0","_npmVersion":"7.11.2","dist":{"shasum":"57e8642b7a77b7a163737e9d25ee187906b48617","size":2830071,"noattachment":false,"key":"/@squoosh/lib/-/@squoosh/lib-0.2.0.tgz","tarball":"http://name.csiicloud.com:7001/@squoosh/lib/download/@squoosh/lib-0.2.0.tgz"},"_npmUser":{"name":"surma","email":"surma@surma.link"},"directories":{},"maintainers":[{"name":"developit","email":""},{"name":"jaffathecake","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/lib_0.2.0_1621423311494_0.052454464933019196"},"_hasShrinkwrap":false,"publish_time":1621423311896,"_cnpm_publish_time":1621423311896,"_cnpmcore_publish_time":"2021-12-16T13:39:43.584Z"},"0.2.0-0":{"name":"@squoosh/lib","version":"0.2.0-0","description":"A Node library for Squoosh","public":true,"main":"/build/index.js","scripts":{"build":"rollup -c"},"keywords":[],"author":{"name":"Google Chrome Developers","email":"chromium-dev@google.com"},"license":"Apache-2.0","dependencies":{"web-streams-polyfill":"^3.0.3"},"devDependencies":{"@babel/core":"^7.14.0","@babel/preset-env":"^7.14.0","@rollup/plugin-babel":"^5.3.0","@rollup/plugin-commonjs":"^18.0.0","@rollup/plugin-node-resolve":"^11.2.1","rollup":"^2.46.0","rollup-plugin-terser":"^7.0.2"},"_id":"@squoosh/lib@0.2.0-0","_nodeVersion":"16.1.0","_npmVersion":"7.11.2","dist":{"shasum":"f914c1d4b3793b6ef7d0f397780af0da9a8a7a55","size":2830073,"noattachment":false,"key":"/@squoosh/lib/-/@squoosh/lib-0.2.0-0.tgz","tarball":"http://name.csiicloud.com:7001/@squoosh/lib/download/@squoosh/lib-0.2.0-0.tgz"},"_npmUser":{"name":"surma","email":"surma@surma.link"},"directories":{},"maintainers":[{"name":"developit","email":""},{"name":"jaffathecake","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/lib_0.2.0-0_1621423068918_0.708909707262521"},"_hasShrinkwrap":false,"publish_time":1621423069201,"_cnpm_publish_time":1621423069201,"_cnpmcore_publish_time":"2021-12-16T13:39:47.119Z"}},"readme":"# Project no longer maintained\n\nUnfortunately, due to a few people leaving the team, and staffing issues resulting from the current economic climate (ugh), this package is no longer actively maintained. I know that sucks, but there simply isn't the time & people to work on this. If anyone from the community wants to fork it, you have my blessing. The [squoosh.app](https://squoosh.app) web app will continue to be supported and improved.\n\n# libSquoosh\n\nlibSquoosh is an _experimental_ way to run all the codecs you know from the [Squoosh] web app directly inside your own JavaScript program. libSquoosh uses a worker pool to parallelize processing images. This way you can apply the same codec to many images at once.\n\nlibSquoosh is currently not the fastest image compression tool in town and doesn’t aim to be. It is, however, fast enough to compress many images sufficiently quick at once.\n\n## Installation\n\nlibSquoosh can be installed to your local project with the following command:\n\n```\n$ npm install @squoosh/lib\n```\n\nYou can start using the libSquoosh by adding these lines to the top of your JS program:\n\n```js\nimport { ImagePool } from '@squoosh/lib';\nimport { cpus } from 'os';\nconst imagePool = new ImagePool(cpus().length);\n```\n\nThis will create an image pool with an underlying processing pipeline that you can use to ingest and encode images. The ImagePool constructor takes one argument that defines how many parallel operations it is allowed to run at any given time.\n\n:warning: Important! Make sure to only create 1 `ImagePool` when performing parallel image processing. If you create multiple pools, the `ImagePool` can run out of memory and crash. By reusing a single `ImagePool`, you can ensure that the backing worker queue and processing pipeline releases memory prior to processing the next image.\n\n## Ingesting images\n\nYou can ingest a new image like so:\n\n```js\nimport fs from 'fs/promises';\nconst file = await fs.readFile('./path/to/image.png');\nconst image = imagePool.ingestImage(file);\n```\n\nThe `ingestImage` function can accept any [`ArrayBuffer`][arraybuffer] whether that is from `readFile()` or `fetch()`.\n\nThe returned `image` object is a representation of the original image, that you can now preprocess, encode, and extract information about.\n\n## Preprocessing and encoding images\n\nWhen an image has been ingested, you can start preprocessing it and encoding it to other formats. This example will resize the image and then encode it to a `.jpg` and `.jxl` image:\n\n```js\nconst preprocessOptions = {\n  //When both width and height are specified, the image resized to specified size.\n  resize: {\n    width: 100,\n    height: 50,\n  },\n  /*\n  //When either width or height is specified, the image resized to specified size keeping aspect ratio.\n  resize: {\n    width: 100,\n  }\n  */\n};\nawait image.preprocess(preprocessOptions);\n\nconst encodeOptions = {\n  mozjpeg: {}, //an empty object means 'use default settings'\n  jxl: {\n    quality: 90,\n  },\n};\nconst result = await image.encode(encodeOptions);\n```\n\nThe default values for each option can be found in the [`codecs.ts`][codecs.ts] file under `defaultEncoderOptions`. Every unspecified value will use the default value specified there. _Better documentation is needed here._\n\nYou can run your own code inbetween the different steps, if, for example, you want to change how much the image should be resized based on its original height. (See [Extracting image information](#extracting-image-information) to learn how to get the image dimensions).\n\n## Closing the ImagePool\n\nWhen you have encoded everything you need, it is recommended to close the processing pipeline in the ImagePool. This will not delete the images you have already encoded, but it will prevent you from ingesting and encoding new images.\n\nClose the ImagePool pipeline with this line:\n\n```js\nawait imagePool.close();\n```\n\n## Writing encoded images to the file system\n\nWhen you have encoded an image, you normally want to write it to a file.\n\nThis example takes an image that has been encoded as a `jpg` and writes it to a file:\n\n```js\nconst rawEncodedImage = image.encodedWith.mozjpeg.binary;\n\nfs.writeFile('/path/to/new/image.jpg', rawEncodedImage);\n```\n\nThis example iterates through all encoded versions of the image and writes them to a specific path:\n\n```js\nconst newImagePath = '/path/to/image.'; //extension is added automatically\n\nfor (const encodedImage of Object.values(image.encodedWith)) {\n  fs.writeFile(newImagePath + encodedImage.extension, encodedImage.binary);\n}\n```\n\n## Extracting image information\n\nInformation about a decoded image is available at `Image.decoded`. It looks something like this:\n\n```js\nconsole.log(await image.decoded);\n// Returns:\n{\n bitmap: {\n    data: Uint8ClampedArray(47736584) [\n      225, 228, 237, 255, 225, 228, 237, 255, 225, 228, 237, 255,\n      225, 228, 237, 255, 225, 228, 237, 255, 225, 228, 237, 255,\n      225, 228, 237, 255,\n      ... //the entire raw image\n    ],\n    width: 4606,  //pixels\n    height: 2591  //pixels\n  },\n  size: 2467795  //bytes\n}\n```\n\nInformation about an encoded image can be found at `Image.encodedWith[encoderName]`. It looks something like this:\n\n```js\nconsole.log(image.encodedWith.jxl);\n// Returns:\n{\n  optionsUsed: {\n    quality: 75,\n    baseline: false,\n    arithmetic: false,\n    progressive: true,\n    ... //all the possible options for this encoder\n  },\n  binary: Uint8Array(1266975) [\n      1,   0,   0,   1,   0,  1,  0,  0, 255, 219,  0, 132,\n    113, 119, 156, 156, 209,  1,  8,  8,   8,   8,  9,   8,\n      9,  10,  10,   9,\n    ... //the entire raw encoded image\n  ],\n  extension: 'jxl',\n  size: 1266975  //bytes\n}\n```\n\n## Auto optimizer\n\nlibSquoosh has an _experimental_ auto optimizer that compresses an image as much as possible, trying to hit a specific [Butteraugli] target value. The higher the Butteraugli target value, the more artifacts can be introduced.\n\nYou can make use of the auto optimizer by using “auto” as the config object.\n\n```js\nconst encodeOptions: {\n  mozjpeg: 'auto',\n}\n```\n\n[squoosh]: https://squoosh.app\n[codecs.ts]: https://github.com/GoogleChromeLabs/squoosh/blob/dev/libsquoosh/src/codecs.ts\n[butteraugli]: https://github.com/google/butteraugli\n[arraybuffer]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer\n","_attachments":{},"homepage":"https://github.com/GoogleChromeLabs/squoosh","bugs":{"url":"https://github.com/GoogleChromeLabs/squoosh/issues"},"license":"Apache-2.0"}