{"bugs":{"url":"https://github.com/jimp-dev/jimp/issues"},"dist":{"shasum":"b93c56c4a5dcb22aac0bb9be6ed6b3818a4a93a1","tarball":"https://registry.npmjs.org/@jimp/custom/-/custom-0.17.9--canary.fc042e5.0.tgz","fileCount":12,"integrity":"sha512-OydlmjT3dsqJeoc8iWgIQFrWcbHkwdqjmR+Jkl7HgzOVpthe/7+qtY4ygwckrrKXQjEgDpcLCsoQDqoTA+Gtuw==","signatures":[{"sig":"MEUCIQDqyCaYVd8ZMIOzgdvdXdYS4NMzkn8Xc6pwOF/WWP6nbAIgRRQDmLFpnJo2MIDfgGOcQ/A1sTUSr81iDz38Aqxgo58=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":35103,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj3vZtACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmqvhg//U0RhAgXy8PJgFDt9zFKwISyMTO2NuiqeDYZ5JxH4YTbJ79uL\r\n8O7bC7eX8wOqBvTbgNheZNZcrQT+JC39Otw1vI92qwkEKXMU/eQdQnMzozii\r\ngSrW8wiXwtyO1X+5CV3rNnWaVdLiSrV7KU3ftNIay1bJ36lGo4k3fgCLFdaK\r\n3vmjhaehEOnh235lkN4mlxC8GVC5pim55jfmsu91OC8eKOWW/c1G2Gg66PgA\r\nO+ubStXgzt1b5cV+eWzgNB7GbZLN7FZ/lguT6vkktKO9gLT7nqCY+gJclTsa\r\nji7cJW4KKcidtllF/PKUF8xy9VaMv6tFJ9tvcPoAR6PDIPBrtGRnKkfqdKc/\r\nDzYbO7mOi0MtKXjSPE4dsgkcTEY6lUMALMVmFu9H3W9T5MBCJGMUAH+fS35y\r\n7Q1vg54eBnSb9W5IcpJGc9N8C6VYk2aYU+WaAiR3q7jJnJn9oiAjp2xKmX0h\r\neWYaUbM2GqER+ow9f+Owff7zTBPFoQJJ+p4D7LI/UfxBBSoIZ8DAUkWmtJXx\r\nc00MWMYT0e6XFX/JDWIfUqIkPpP2BGaST6XOEhJaxF1Q6f8Eqtsa0LH+Qn1u\r\ngzWF5H0pxqGIsQ8B86mmKAzFweyH/BdEdx1klurv0HNdAc6KDvWQ8SmWJkCz\r\nhQQZEWEOcSmUJuq7VlTUtVzMiXkZJCJPluE=\r\n=79EK\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","name":"@jimp/custom","types":"types/index.d.ts","author":"","module":"es/index.js","readme":"<div align=\"center\">\n  <img width=\"200\" height=\"200\"\n    src=\"https://s3.amazonaws.com/pix.iemoji.com/images/emoji/apple/ios-11/256/crayon.png\">\n  <h1>@jimp/custom</h1>\n  <p>Configure jimp with types and plugins.</p>\n</div>\n\n## Useful Defaults\n\nThe following wil configure a `jimp` instance with the same functionality as the main `jimp` package.\n\n```js\nimport configure from \"@jimp/custom\";\n// all of jimp's default types\nimport types from \"@jimp/types\";\n// all of jimp's default types\nimport plugins from \"@jimp/plugins\";\n\nconfigure({\n  types: [types],\n  plugins: [plugins],\n});\n```\n\n## Available Methods\n\n### configure\n\nTakes a Jimp configuration and applies it to `@jimp/core`.\n\nSample Jimp configuration:\n\n```js\nimport types from '@jimp/types';\n\nimport bmp from '@jimp/bmp';\nimport jpeg from '@jimp/types';\n...\n\nconfigure({\n  types: [types]\n})\n\n// or\n\nconfigure({\n  types: [bmp, jpeg, ...]\n})\n```\n\n#### Extending Jimp Further\n\nYou can use configure to add more types and plugins to a jimp multiple times.\n\n```js\nlet jimp = configure({\n  types: [bmp],\n});\n\njimp = configure(\n  {\n    types: [jpeg],\n  },\n  jimp\n);\n```\n\n## Type Definition\n\nTo define a new Jimp image type write a function the takes the current Jimp configuration. In this function you can extend Jimp's internal data structures.\n\nThis function must return an object whose key is the mime type and value is an array of valid file extensions.\n\n```js\nconst special = require('special-js');\n\nconst MIME_TYPE = 'image/special';\n\nexport default () => ({\n  mime: {[MIME_TYPE], ['spec', 'special']},\n\n  constants: {\n    MIME_SPECIAL: MIME_TYPE\n  },\n\n  decoders: {\n    [MIME_TYPE]: data => special.decode(data)\n  },\n\n  encoders: {\n    [MIME_TYPE]: image => special.encode(image.bitmap)\n  }\n});\n```\n\n### Constants\n\nA jimp image type can expose as many constants as it wants. Each jimp type is required to expose a mime type.\n\n```js\nconstants: {\n  MIME_SPECIAL: MIME_TYPE\n},\n```\n\n### hasAlpha\n\nA image type can define whether it supports an alpha channel.\n\n```js\nhasAlpha: {\n  MIME_SPECIAL: true\n},\n```\n\n### Decoder\n\nA function that when supplied with a buffer should return a bitmap with height and width.\n\n```js\ndecoders: {\n  [MIME_TYPE]: data => special.decode(data)\n},\n```\n\n### Encoder\n\nA function that when supplied with a Jimp image should return an encoded buffer.\n\n```js\nencoders: {\n  [MIME_TYPE]: image => special.encode(image.bitmap)\n}\n```\n\n### Class\n\nAdd class properties and function to the Jimp constructor.\n\n```js\nclass: {\n  _quality: 100,\n  quality: function(n, cb) {\n    if (typeof n !== 'number') {\n      return throwError.call(this, 'n must be a number', cb);\n    }\n\n    if (n < 0 || n > 100) {\n      return throwError.call(this, 'n must be a number 0 - 100', cb);\n    }\n\n    this._quality = Math.round(n);\n\n    if (isNodePattern(cb)) {\n      cb.call(this, null, this);\n    }\n\n    return this;\n  }\n};\n```\n\n## Plugin Definition\n\nDefining a plugin has access to all the same things in the type definition. Mainly plugins use just the `constants` and `class` config options.\n\nBelow is the `invert` plugin. If a plugin doesn return an object with `constants` and `class`, all keys are treated as class functions.\n\n```js\nimport { isNodePattern } from \"@jimp/utils\";\n\n/**\n * Inverts the image\n * @param {function(Error, Jimp)} cb (optional) a callback for when complete\n * @returns {Jimp} this for chaining of methods\n */\nexport default () => ({\n  invert(cb) {\n    this.scanQuiet(\n      0,\n      0,\n      this.bitmap.width,\n      this.bitmap.height,\n      function (x, y, idx) {\n        this.bitmap.data[idx] = 255 - this.bitmap.data[idx];\n        this.bitmap.data[idx + 1] = 255 - this.bitmap.data[idx + 1];\n        this.bitmap.data[idx + 2] = 255 - this.bitmap.data[idx + 2];\n      }\n    );\n\n    if (isNodePattern(cb)) {\n      cb.call(this, null, this);\n    }\n\n    return this;\n  },\n});\n```\n","gitHead":"fc042e51bbef0deaf7908150ecdbdca36863506d","license":"MIT","scripts":{"build":"npm run build:node:production && npm run build:module","build:node":"babel src -d dist --source-maps --config-file ../../babel.config.js","build:debug":"npm run build:node:debug","build:watch":"npm run build:node:debug -- -- --watch --verbose","build:module":"cross-env BABEL_ENV=module babel src -d es --source-maps --config-file ../../babel.config.js","build:node:debug":"cross-env BABEL_ENV=development npm run build:node","build:node:production":"cross-env BABEL_ENV=production npm run build:node"},"_npmUser":{"name":"alisowski","email":"lisowski54@gmail.com"},"homepage":"https://github.com/jimp-dev/jimp#readme","repository":{"url":"git+https://github.com/jimp-dev/jimp.git","type":"git"},"_npmVersion":"lerna/3.16.4/node@v16.18.1+x64 (linux)","description":"Interface to customize jimp configuration","directories":{},"maintainers":[{"name":"alisowski","email":"lisowski54@gmail.com"},{"name":"oliver.moran","email":"oliver@nth-iteration.ie"}],"_nodeVersion":"16.18.1","dependencies":{"@jimp/core":"0.17.9--canary.fc042e5.0","@babel/runtime":"^7.7.2"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/custom_0.17.9--canary.fc042e5.0_1675556460943_0.6418350663625956","host":"s3://npm-registry-packages"},"_id":"@jimp/custom@0.17.9--canary.fc042e5.0","version":"0.17.9--canary.fc042e5.0"}