{"_id":"@di9/jpeg-turbo","_rev":"3-9abf9baf94c120e427737aa33935db33","name":"@di9/jpeg-turbo","dist-tags":{"latest":"1.1.3"},"versions":{"1.1.2":{"name":"@di9/jpeg-turbo","version":"1.1.2","description":"Limited libjpeg-turbo bindings for Node.js.","keywords":["jpeg","jpeg-turbo","libjpeg-turbo"],"license":"Apache-2.0","repository":{"type":"git","url":"git+https://github.com/julusian/node-jpeg-turbo.git"},"binary":{"napi_versions":[3]},"engines":{"node":">=10"},"main":"./index.js","types":"./module.d.ts","dependencies":{"bindings":"^1.5.0","cmake-js":"^6.2.1","node-addon-api":"^3.2.1","prebuild-install":"^6.1.3"},"scripts":{"install":"prebuild-install -r napi || cmake-js compile --target jpegturbo","prebuild":"prebuild -r napi --all --verbose --backend cmake-js -- --target jpegturbo","test":"jest"},"devDependencies":{"jest":"^26.6.3","prebuild":"^10.0.0"},"bugs":{"url":"https://github.com/julusian/node-jpeg-turbo/issues"},"homepage":"https://github.com/julusian/node-jpeg-turbo#readme","directories":{"test":"tests"},"author":"","gitHead":"1e1ff80dacadee964e6c56ac3a60be3e2d9e4053","_id":"@di9/jpeg-turbo@1.1.2","_nodeVersion":"14.16.1","_npmVersion":"6.14.12","dist":{"integrity":"sha512-G+ObeD/MzijSZOgJ1T7aiqKL/Ub0Trl7SjCyp7yXorwIsngPoUTwFork790CD8k16o0esLPRhM60tzAeBmnnAA==","shasum":"2b4d48b2e5785537817a2593518997dcf297746f","tarball":"https://registry.npmjs.org/@di9/jpeg-turbo/-/jpeg-turbo-1.1.2.tgz","fileCount":370,"unpackedSize":5513130,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGMyuaNH+GjhAW5UITB39Ef3RCu4hx6nf7SG4Bxj7oxJAiAYOdUIZi2KDlbMnhL4eSRszrsP3HrvoTwsDPTGnvG1ow=="}]},"_npmUser":{"name":"di9","email":"other@ytka.org"},"maintainers":[{"name":"di9","email":"other@ytka.org"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/jpeg-turbo_1.1.2_1632842431162_0.229602575651364"},"_hasShrinkwrap":false},"1.1.3":{"name":"@di9/jpeg-turbo","version":"1.1.3","description":"Limited libjpeg-turbo bindings for Node.js.","keywords":["jpeg","jpeg-turbo","libjpeg-turbo"],"license":"Apache-2.0","repository":{"type":"git","url":"git+https://github.com/julusian/node-jpeg-turbo.git"},"binary":{"napi_versions":[3]},"engines":{"node":">=10"},"main":"./index.js","types":"./module.d.ts","dependencies":{"bindings":"^1.5.0","cmake-js":"^6.2.1","node-addon-api":"^3.2.1","prebuild-install":"^6.1.3"},"scripts":{"install":"prebuild-install -r napi || cmake-js compile --target jpegturbo","prebuild":"prebuild -r napi --all --verbose --backend cmake-js -- --target jpegturbo","test":"jest"},"devDependencies":{"jest":"^26.6.3","prebuild":"^10.0.0"},"bugs":{"url":"https://github.com/di9/node-jpeg-turbo/issues"},"homepage":"https://github.com/di9/node-jpeg-turbo#readme","directories":{"test":"tests"},"author":"","gitHead":"1e1ff80dacadee964e6c56ac3a60be3e2d9e4053","_id":"@di9/jpeg-turbo@1.1.3","_nodeVersion":"14.16.1","_npmVersion":"6.14.12","dist":{"integrity":"sha512-/VavjqIlNwzi40qQXdA1ZtD/Dxzc0OrEyqp0zbmS5YGDG8wW3/J1h5iSvHtDrA1xE4ixk06vw1J/ygD7DMKUew==","shasum":"68ae7bec866216e4f4dc46539624db778279e8f0","tarball":"https://registry.npmjs.org/@di9/jpeg-turbo/-/jpeg-turbo-1.1.3.tgz","fileCount":370,"unpackedSize":5513120,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhzwc8CRA9TVsSAnZWagAA5YMP+QAg78gD0oqXzwtRqgq3\nPbcd97BD+F3IAGmhLSFRkWOeEE9uGzEBGIVfJPBlO0nxDT1WvFFgJUBNAqzM\nqe5UNmOE9Nf0ksZntfrlXVFFCgXcxl6LIF0EyhB6jZfeYfBD/3mqqm3BZWqi\nyt4xtqy2JXJjcHUv0UnpMD4vinI7EZ6+ncfhHjyedZPqg/HEH7NeLCMqZqA6\nWshjaTos90sNmrTrdJKyxgbrd7QMjPM7bbL4s9XxTm+vzA9vbA39U/jSq6z/\nF95iJx2p8qv4jhXUCfidKqZ7O08cmDW37Mmc5EeZFDPxi6RFJkTh3VK7jTI+\n5585EDoqIW7diP9/ysmgEsEKSE/tFLcjQqbZ3WJ6OxkDmm6zAMTNrvhI+Rz0\n8w7jZTN4PxIxKt3DPNzghZpAwSF0+PczKdmHMbRJqQKlWat6vLIBJR+Z/f+y\nkD+vMqCos4LmNit6voYOgDWwUaQ+uGWn1r9bYSRSC2WJjJwC0gNfuz6reRqX\nUVli0OOU4S9/IA+GU53g5EpFwWJhSoqFXOcsWNlLgpqSlNvUVaTYxs6JOqeN\nZbTF7lOV7F8EMRuGUoVZJsTCtZtnr6TdvMzfdDOQN3BCuLO3wSxRQwnZJ7ib\nY+mECDaDKuvxx7GerXE2AAwHFVOoG+Zs2FjkhQAAGT/OMCiXowx5AslLu9Gb\n11cA\r\n=ShLL\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBGEAeXwC6ojfeqzZAjzDMGZBTz1+fOBdjuSDVhKFtu/AiBnYJG9nNtLFZcvoA5mbk8Wdz5jfmbueY+DynAbndDY9Q=="}]},"_npmUser":{"name":"di9","email":"other@ytka.org"},"maintainers":[{"name":"di9","email":"other@ytka.org"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/jpeg-turbo_1.1.3_1632842545593_0.5708702140025206"},"_hasShrinkwrap":false}},"time":{"created":"2021-09-28T15:20:31.044Z","1.1.2":"2021-09-28T15:20:31.402Z","modified":"2022-04-05T04:21:04.590Z","1.1.3":"2021-09-28T15:22:25.839Z"},"maintainers":[{"name":"di9","email":"other@ytka.org"}],"description":"Limited libjpeg-turbo bindings for Node.js.","homepage":"https://github.com/di9/node-jpeg-turbo#readme","keywords":["jpeg","jpeg-turbo","libjpeg-turbo"],"repository":{"type":"git","url":"git+https://github.com/julusian/node-jpeg-turbo.git"},"bugs":{"url":"https://github.com/di9/node-jpeg-turbo/issues"},"license":"Apache-2.0","readme":"# @julusian/jpeg-turbo\n\n![Node CI](https://github.com/Julusian/node-jpeg-turbo/workflows/Node%20CI/badge.svg)\n[![npm](https://img.shields.io/npm/v/@julusian/jpeg-turbo.svg)](https://www.npmjs.com/package/@julusian/jpeg-turbo)\n[![npm](https://img.shields.io/npm/dm/@julusian/jpeg-turbo.svg)](https://www.npmjs.com/package/@julusian/jpeg-turbo)\n[![npm](https://img.shields.io/npm/l/@julusian/jpeg-turbo.svg)](LICENSE)\n\nThis is a fork of [jpeg-turbo](https://github.com/sorccu/node-jpeg-turbo) with the intention of being maintained and bringing support for new versions of node\n\n**node-jpeg-turbo** provides minimal [libjpeg-turbo](http://libjpeg-turbo.org/) bindings for [Node.js](https://nodejs.org/). It is very, very fast compared to other alternatives, such as [node-imagemagick-native](https://github.com/mash/node-imagemagick-native) or [jpeg-js](https://github.com/eugeneware/jpeg-js).\n\nPlease ask if you need more methods exposed.\n\n## Requirements\n\nAll versions of Node still in [*active* Long-term Support](https://github.com/nodejs/LTS#lts-schedule) and the current development version are supported. Older versions may or may not work; they are not and will not be supported.\n\nWe provide prebuilds for some platforms, meaning that you should not have to compile native bindings from source very often. The bindings are hosted at and automatically installed from our [GitHub Releases](https://github.com/julusian/node-jpeg-turbo).\n\n### If you must build from source\n\nFirst, if you're building from the repo, make sure to init and update submodules or you'll get confusing errors about missing targets when building. We include `libjpeg-turbo` as a submodule.\n\n```bash\ngit submodule init\ngit submodule update\n```\n\n(or just use `git clone --recursive` when cloning the repo)\n\nWe build `libjpeg-turbo` directly with `cmake`, so both `cmake` and `yasm` are required on your machine. `yasm` is only required on x86 and x86_64 architectures.\n\nTo install:\n\n**On OS X**\n\n```bash\nbrew install yasm\nbrew install cmake\n```\n\n**On Ubuntu/Debian**\n\n```bash\napt-get install yasm cmake\n```\n\n**On Windows**\n\nDownload and install the latest from [here](https://cmake.org/download/). Make sure to select the option to put it on path for all users.\n\nDownload Win32 or Win64 yasm from [here](http://yasm.tortall.net/Download.html) and make sure it's found in path as yasm.exe. Use the \"for general use\" version. If the .exe doesn't run, or complains about a missing `MSVCR100.dll`, you can install the missing VS2010 Redist x64 from [KB2977003](https://www.microsoft.com/en-gb/download/details.aspx?id=14632). The .exe should work fine after installing the redistributable.\n\nTo verify your yasm setup, run:\n\n```sh\nyasm\n```\n\nThis should give the output:\n\n> yasm: No input files specified\n\nNext, you need to make sure that you have a build environment set up. An easy way to do that is to use [windows-build-tools](https://github.com/felixrieseberg/windows-build-tools).\n\nNow, just to make sure things are set up properly, run:\n\n```\nnpm config get msvs_version\n```\n\nIf the output is `2015` or newer, you're good. If it's anything else, or not set, you must run:\n\n```\nnpm config set -g msvs_version 2015\n```\n\nAlternatively, you can specify the option at install time with `--msvs_version=2015`.\n\n**Others**\n\nSearch your package manager for `yasm`.\n\n## Installation\n\nMake sure you've got the [requirements](#requirements) installed first.\n\nUsing [yarn](https://yarnpkg.com/):\n\n```sh\nyarn add @julusian/jpeg-turbo\n```\n\nUsing [npm](https://www.npmjs.com/):\n\n```sh\nnpm install --save @julusian/jpeg-turbo\n```\n\n## API\n\n### `jpg.bufferSize(options)` → `Number`\n\nIf you'd like to preallocate a `Buffer` for `jpg.compressSync()`, use this method to get the worst-case upper bound. The `options` argument is fully compatible with the `jpg.compressSync()` method, so that you can pass the same options to both functions.\n\n* **options** is an Object with the following properties:\n  - **width** Required. The width of the image.\n  - **height** Required. The height of the image.\n  - **subsampling** Optional. The subsampling method to use. Defaults to `jpg.SAMP_420`.\n* **Returns** The `Number` of bytes required in a worst-case scenario.\n\n```js\nvar fs = require('fs')\nvar jpg = require('@julusian/jpeg-turbo')\n\nvar raw = fs.readFileSync('raw.rgba')\n\nvar options = {\n  format: jpg.FORMAT_RGBA,\n  width: 1080,\n  height: 1920,\n  subsampling: jpg.SAMP_444,\n}\n\nvar preallocated = new Buffer(jpg.bufferSize(options))\n\nvar encoded = jpg.compressSync(raw, preallocated, options)\n```\n\n### `jpg.compressSync(raw[, out], options)` → `Object`\n\nCompresses (i.e. encodes) the raw pixel data into a JPG. This method is not capable of resizing the image.\n\nFor efficiency reasons you may choose to encode into a preallocated `Buffer`. While fast, it has a number of drawbacks. Namely, you'll have to be careful not to reuse the buffer in async processing before processing (e.g. saving, displaying or transmitting) the entire encoded image. Otherwise you risk corrupting the image. Also, it wastes a huge amount of space compared to on-demand allocation.\n\n* **raw** is a `Buffer` with the raw pixel data in `options.format`.\n* **out** is an optional preallocated `Buffer` for the encoded image. The size of the buffer is checked. See `jpg.bufferSize()` for an example of how to preallocate a sufficient `Buffer`. If not given, memory is allocated and reallocated as needed, which eliminates most of the wasted space but is slower and lacks consistency with varying source images.\n* **options** is an Object with the following properties:\n  - **format** Required. The format of the `raw` pixel data (e.g. `jpg.FORMAT_RGBA`).\n  - **width** Required. The width of the image.\n  - **height** Required. The height of the image.\n  - **subsampling** Optional. The subsampling method to use. Defaults to `jpg.SAMP_420`.\n  - **quality** Optional. The desired JPG quality. Defaults to 80.\n* **Returns** An `Object` with the following properties:\n  - **data** The encoded image as a `Buffer`. Note that the buffer may actually be a slice of the preallocated `Buffer`, if given. _**Be careful not to reuse the preallocated buffer before you've finished processing the encoded image, as it may corrupt the image.**_\n  - **size** The size of the used space in the buffer\n\n```js\nvar fs = require('fs')\nvar jpg = require('@julusian/jpeg-turbo')\n\nvar raw = fs.readFileSync('raw.rgba')\n\nvar options = {\n  format: jpg.FORMAT_RGBA,\n  width: 1080,\n  height: 1920,\n  subsampling: jpg.SAMP_444,\n}\n\nvar encoded = jpg.compressSync(raw, options)\n```\n\nSee `jpg.bufferSize()` for an example of preallocated `Buffer` usage.\n\n\n### `jpg.decompressSync(image[, out], options)` → `Object`\n\nDecompresses (i.e. decodes) the JPG image into raw pixel data.\n\n* **image** is a `Buffer` with the JPG image data.\n* **out** is an optional preallocated `Buffer` for the decoded image. The size of the buffer is checked, and should be at least `width * height * bytes_per_pixel` or larger. If not given, one is created for you. The only benefit of providing the `Buffer` yourself is that you can reuse the same buffer between multiple `jpg.decompressSync()` calls. Note that this can lead to issues with concurrency. See `jpg.compressSync()` for related discussion.\n* **options** is an Object with the following properties:\n  - **format** Required. The desired format of the `raw` pixel data (e.g. `jpg.FORMAT_RGBA`).\n  - **out** _Deprecated._ Use the `out` argument instead.\n* **Returns** An `Object` with the following properties:\n  - **data** A `Buffer` with the raw pixel data.\n  - **width** The width of the image.\n  - **height** The height of the image.\n  - **subsampling**  The subsampling method used in the JPG.\n  - **size** _Deprecated._ Use `data.length` instead.\n  - **bpp** The number of bytes per pixel.\n\n```js\nvar fs = require('fs')\nvar jpg = require('@julusian/jpeg-turbo')\n\nvar image = fs.readFileSync('image.jpg')\n\nvar options = {\n  format: jpg.FORMAT_RGBA,\n}\n\nvar decoded = jpg.decompressSync(image, options)\n```\n\n## Thanks\n\n* https://github.com/A2K/node-jpeg-turbo-scaler\n* https://github.com/mash/node-imagemagick-native\n* https://github.com/google/skia/blob/master/gyp/libjpeg-turbo.gyp\n* https://github.com/openstf/android-libjpeg-turbo\n\n## License\n\nSee [LICENSE](LICENSE).\n\nCopyright © Julian Waller. All Rights Reserved.\n","readmeFilename":"README.md"}