{"version":3,"file":"index.js","names":["fs","Path","EventEmitter","isNodePattern","throwError","scan","scanIterator","anyBase","pixelMatch","tinyColor","ImagePHash","request","composite","promisify","MIME","parseBitmap","getBuffer","getBufferAsync","constants","alphabet","maxHashLength","NaN","i","maxHash","BIN","slice","Array","join","push","length","noop","isArrayBuffer","test","Object","prototype","toString","call","toLowerCase","indexOf","bufferFromArrayBuffer","arrayBuffer","buffer","Buffer","alloc","byteLength","view","Uint8Array","loadFromURL","options","cb","err","data","isBuffer","Error","url","loadBufferFromPath","src","readFile","match","isRawRGBAData","obj","width","height","Uint8ClampedArray","makeRGBABufferFromRGB","rgbaBuffer","allocUnsafe","j","emptyBitmap","Jimp","constructor","args","MIME_PNG","path","write","mime","getBase64","getPixelColor","setPixelColor","jimpInstance","finish","evData","methodName","setTimeout","emitError","emitMulti","parseInt","w","h","_background","cssColorToHex","bitmap","writeUInt32BE","original","from","_quality","_deflateLevel","_deflateStrategy","_filterType","_rgba","_originalMime","imageData","isRGBA","extraConstructor","__extraConstructors","find","c","Promise","resolve","reject","run","then","catch","rgba","bool","eventName","assign","emit","getHeight","getWidth","inspect","getMIME","getExtension","createWriteStream","getType","pathObj","parse","dir","mkdirSync","recursive","stream","on","end","AUTO","hash","base","pHash","getHash","distanceFromHash","compareHash","currentHash","distance","getPixelIndex","x","y","edgeHandling","xi","yi","EDGE_EXTEND","Math","round","EDGE_WRAP","idx","hex","readUInt32BE","hasAlpha","byteLen","addConstants","entries","forEach","name","value","addJimpMethods","methods","appendConstructorOption","read","image","create","rgbaToInt","r","g","b","a","intToRGBA","floor","pow","cssColor","Number","toHex8","limit255","n","max","min","diff","img1","img2","threshold","bmp1","bmp2","cloneQuiet","resize","numDiffPixels","percent","phash","hash1","hash2","compareHashes","colorDiff","rgba1","rgba2","maxVal","jimpEvMethod","evName","method","evNameBefore","evNameAfter","replace","wrappedCb","apply","result","error","clone","jimpEvChange","f","process","env","ENVIRONMENT","gl","window","self","addType"],"sources":["../src/index.js"],"sourcesContent":["import fs from \"fs\";\nimport Path from \"path\";\nimport EventEmitter from \"events\";\n\nimport { isNodePattern, throwError, scan, scanIterator } from \"@jimp/utils\";\nimport anyBase from \"any-base\";\nimport pixelMatch from \"pixelmatch\";\nimport tinyColor from \"tinycolor2\";\n\nimport ImagePHash from \"./modules/phash\";\nimport request from \"./request\";\n\nimport composite from \"./composite\";\nimport promisify from \"./utils/promisify\";\nimport * as MIME from \"./utils/mime\";\nimport { parseBitmap, getBuffer, getBufferAsync } from \"./utils/image-bitmap\";\nimport * as constants from \"./constants\";\n\nconst alphabet =\n \"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_\";\n\n// an array storing the maximum string length of hashes at various bases\n// 0 and 1 do not exist as possible hash lengths\nconst maxHashLength = [NaN, NaN];\n\nfor (let i = 2; i < 65; i++) {\n const maxHash = anyBase(\n anyBase.BIN,\n alphabet.slice(0, i)\n )(new Array(64 + 1).join(\"1\"));\n maxHashLength.push(maxHash.length);\n}\n\n// no operation\nfunction noop() {}\n\n// error checking methods\n\nfunction isArrayBuffer(test) {\n return (\n Object.prototype.toString.call(test).toLowerCase().indexOf(\"arraybuffer\") >\n -1\n );\n}\n\n// Prepare a Buffer object from the arrayBuffer. Necessary in the browser > node conversion,\n// But this function is not useful when running in node directly\nfunction bufferFromArrayBuffer(arrayBuffer) {\n const buffer = Buffer.alloc(arrayBuffer.byteLength);\n const view = new Uint8Array(arrayBuffer);\n\n for (let i = 0; i < buffer.length; ++i) {\n buffer[i] = view[i];\n }\n\n return buffer;\n}\n\nfunction loadFromURL(options, cb) {\n request(options, (err, data) => {\n if (err) {\n return cb(err);\n }\n\n if (typeof data === \"object\" && Buffer.isBuffer(data)) {\n return cb(null, data);\n }\n\n if (typeof data === \"object\" && isArrayBuffer(data)) {\n return cb(null, bufferFromArrayBuffer(data));\n }\n\n return new Error(`Could not load Buffer from <${options.url}>`);\n });\n}\n\nfunction loadBufferFromPath(src, cb) {\n if (\n fs &&\n typeof fs.readFile === \"function\" &&\n !src.match(/^(http|ftp)s?:\\/\\/./)\n ) {\n fs.readFile(src, cb);\n } else {\n loadFromURL({ url: src }, cb);\n }\n}\n\nfunction isRawRGBAData(obj) {\n return (\n obj &&\n typeof obj === \"object\" &&\n typeof obj.width === \"number\" &&\n typeof obj.height === \"number\" &&\n (Buffer.isBuffer(obj.data) ||\n obj.data instanceof Uint8Array ||\n (typeof Uint8ClampedArray === \"function\" &&\n obj.data instanceof Uint8ClampedArray)) &&\n (obj.data.length === obj.width * obj.height * 4 ||\n obj.data.length === obj.width * obj.height * 3)\n );\n}\n\nfunction makeRGBABufferFromRGB(buffer) {\n if (buffer.length % 3 !== 0) {\n throw new Error(\"Buffer length is incorrect\");\n }\n\n const rgbaBuffer = Buffer.allocUnsafe((buffer.length / 3) * 4);\n let j = 0;\n\n for (let i = 0; i < buffer.length; i++) {\n rgbaBuffer[j] = buffer[i];\n\n if ((i + 1) % 3 === 0) {\n rgbaBuffer[++j] = 255;\n }\n\n j++;\n }\n\n return rgbaBuffer;\n}\n\nconst emptyBitmap = {\n data: null,\n width: null,\n height: null,\n};\n\n/**\n * Jimp constructor (from a file)\n * @param path a path to the image\n * @param {function(Error, Jimp)} cb (optional) a function to call when the image is parsed to a bitmap\n */\n\n/**\n * Jimp constructor (from a url with options)\n * @param options { url, otherOptions}\n * @param {function(Error, Jimp)} cb (optional) a function to call when the image is parsed to a bitmap\n */\n\n/**\n * Jimp constructor (from another Jimp image or raw image data)\n * @param image a Jimp image to clone\n * @param {function(Error, Jimp)} cb a function to call when the image is parsed to a bitmap\n */\n\n/**\n * Jimp constructor (from a Buffer)\n * @param data a Buffer containing the image data\n * @param {function(Error, Jimp)} cb a function to call when the image is parsed to a bitmap\n */\n\n/**\n * Jimp constructor (to generate a new image)\n * @param w the width of the image\n * @param h the height of the image\n * @param {function(Error, Jimp)} cb (optional) a function to call when the image is parsed to a bitmap\n */\n\n/**\n * Jimp constructor (to generate a new image)\n * @param w the width of the image\n * @param h the height of the image\n * @param background color to fill the image with\n * @param {function(Error, Jimp)} cb (optional) a function to call when the image is parsed to a bitmap\n */\n\nclass Jimp extends EventEmitter {\n // An object representing a bitmap in memory, comprising:\n // - data: a buffer of the bitmap data\n // - width: the width of the image in pixels\n // - height: the height of the image in pixels\n bitmap = emptyBitmap;\n\n // Default colour to use for new pixels\n _background = 0x00000000;\n\n // Default MIME is PNG\n _originalMime = Jimp.MIME_PNG;\n\n // Exif data for the image\n _exif = null;\n\n // Whether Transparency supporting formats will be exported as RGB or RGBA\n _rgba = true;\n\n constructor(...args) {\n super();\n\n const jimpInstance = this;\n let cb = noop;\n\n if (isArrayBuffer(args[0])) {\n args[0] = bufferFromArrayBuffer(args[0]);\n }\n\n function finish(...args) {\n const [err] = args;\n const evData = err || {};\n evData.methodName = \"constructor\";\n\n setTimeout(() => {\n // run on next tick.\n if (err && cb === noop) {\n jimpInstance.emitError(\"constructor\", err);\n } else if (!err) {\n jimpInstance.emitMulti(\"constructor\", \"initialized\");\n }\n\n cb.call(jimpInstance, ...args);\n }, 1);\n }\n\n if (\n (typeof args[0] === \"number\" && typeof args[1] === \"number\") ||\n (parseInt(args[0], 10) && parseInt(args[1], 10))\n ) {\n // create a new image\n const w = parseInt(args[0], 10);\n const h = parseInt(args[1], 10);\n cb = args[2];\n\n // with a hex color\n if (typeof args[2] === \"number\") {\n this._background = args[2];\n cb = args[3];\n }\n\n // with a css color\n if (typeof args[2] === \"string\") {\n this._background = Jimp.cssColorToHex(args[2]);\n cb = args[3];\n }\n\n if (typeof cb === \"undefined\") {\n cb = noop;\n }\n\n if (typeof cb !== \"function\") {\n return throwError.call(this, \"cb must be a function\", finish);\n }\n\n this.bitmap = {\n data: Buffer.alloc(w * h * 4),\n width: w,\n height: h,\n };\n\n for (let i = 0; i < this.bitmap.data.length; i += 4) {\n this.bitmap.data.writeUInt32BE(this._background, i);\n }\n\n finish(null, this);\n } else if (typeof args[0] === \"object\" && args[0].url) {\n cb = args[1] || noop;\n\n if (typeof cb !== \"function\") {\n return throwError.call(this, \"cb must be a function\", finish);\n }\n\n loadFromURL(args[0], (err, data) => {\n if (err) {\n return throwError.call(this, err, finish);\n }\n\n this.parseBitmap(data, args[0].url, finish);\n });\n } else if (args[0] instanceof Jimp) {\n // clone an existing Jimp\n const [original] = args;\n cb = args[1];\n\n if (typeof cb === \"undefined\") {\n cb = noop;\n }\n\n if (typeof cb !== \"function\") {\n return throwError.call(this, \"cb must be a function\", finish);\n }\n\n this.bitmap = {\n data: Buffer.from(original.bitmap.data),\n width: original.bitmap.width,\n height: original.bitmap.height,\n };\n\n this._quality = original._quality;\n this._deflateLevel = original._deflateLevel;\n this._deflateStrategy = original._deflateStrategy;\n this._filterType = original._filterType;\n this._rgba = original._rgba;\n this._background = original._background;\n this._originalMime = original._originalMime;\n\n finish(null, this);\n } else if (isRawRGBAData(args[0])) {\n const [imageData] = args;\n cb = args[1] || noop;\n\n const isRGBA =\n imageData.width * imageData.height * 4 === imageData.data.length;\n const buffer = isRGBA\n ? Buffer.from(imageData.data)\n : makeRGBABufferFromRGB(imageData.data);\n\n this.bitmap = {\n data: buffer,\n width: imageData.width,\n height: imageData.height,\n };\n\n finish(null, this);\n } else if (typeof args[0] === \"string\") {\n // read from a path\n const path = args[0];\n cb = args[1];\n\n if (typeof cb === \"undefined\") {\n cb = noop;\n }\n\n if (typeof cb !== \"function\") {\n return throwError.call(this, \"cb must be a function\", finish);\n }\n\n loadBufferFromPath(path, (err, data) => {\n if (err) {\n return throwError.call(this, err, finish);\n }\n\n this.parseBitmap(data, path, finish);\n });\n } else if (typeof args[0] === \"object\" && Buffer.isBuffer(args[0])) {\n // read from a buffer\n const data = args[0];\n cb = args[1];\n\n if (typeof cb !== \"function\") {\n return throwError.call(this, \"cb must be a function\", finish);\n }\n\n this.parseBitmap(data, null, finish);\n } else {\n // Allow client libs to add new ways to build a Jimp object.\n // Extra constructors must be added by `Jimp.appendConstructorOption()`\n cb = args[args.length - 1];\n\n if (typeof cb !== \"function\") {\n // TODO: try to solve the args after cb problem.\n cb = args[args.length - 2];\n\n if (typeof cb !== \"function\") {\n cb = noop;\n }\n }\n\n const extraConstructor = Jimp.__extraConstructors.find((c) =>\n c.test(...args)\n );\n\n if (extraConstructor) {\n new Promise((resolve, reject) => {\n extraConstructor.run.call(this, resolve, reject, ...args);\n })\n .then(() => finish(null, this))\n .catch(finish);\n } else {\n return throwError.call(\n this,\n \"No matching constructor overloading was found. \" +\n \"Please see the docs for how to call the Jimp constructor.\",\n finish\n );\n }\n }\n }\n\n /**\n * Parse a bitmap with the loaded image types.\n *\n * @param {Buffer} data raw image data\n * @param {string} path optional path to file\n * @param {function(Error, Jimp)} finish (optional) a callback for when complete\n * @memberof Jimp\n */\n parseBitmap(data, path, finish) {\n parseBitmap.call(this, data, null, finish);\n }\n\n /**\n * Sets the type of the image (RGB or RGBA) when saving in a format that supports transparency (default is RGBA)\n * @param {boolean} bool A Boolean, true to use RGBA or false to use RGB\n * @param {function(Error, Jimp)} cb (optional) a callback for when complete\n * @returns {Jimp} this for chaining of methods\n */\n rgba(bool, cb) {\n if (typeof bool !== \"boolean\") {\n return throwError.call(\n this,\n \"bool must be a boolean, true for RGBA or false for RGB\",\n cb\n );\n }\n\n this._rgba = bool;\n\n if (isNodePattern(cb)) {\n cb.call(this, null, this);\n }\n\n return this;\n }\n\n /**\n * Emit for multiple listeners\n * @param {string} methodName name of the method to emit an error for\n * @param {string} eventName name of the eventName to emit an error for\n * @param {object} data to emit\n */\n emitMulti(methodName, eventName, data = {}) {\n data = Object.assign(data, { methodName, eventName });\n this.emit(\"any\", data);\n\n if (methodName) {\n this.emit(methodName, data);\n }\n\n this.emit(eventName, data);\n }\n\n emitError(methodName, err) {\n this.emitMulti(methodName, \"error\", err);\n }\n\n /**\n * Get the current height of the image\n * @return {number} height of the image\n */\n getHeight() {\n return this.bitmap.height;\n }\n\n /**\n * Get the current width of the image\n * @return {number} width of the image\n */\n getWidth() {\n return this.bitmap.width;\n }\n\n /**\n * Nicely format Jimp object when sent to the console e.g. console.log(image)\n * @returns {string} pretty printed\n */\n inspect() {\n return (\n \"\"\n );\n }\n\n /**\n * Nicely format Jimp object when converted to a string\n * @returns {string} pretty printed\n */\n toString() {\n return \"[object Jimp]\";\n }\n\n /**\n * Returns the original MIME of the image (default: \"image/png\")\n * @returns {string} the MIME\n */\n getMIME() {\n const mime = this._originalMime || Jimp.MIME_PNG;\n\n return mime;\n }\n\n /**\n * Returns the appropriate file extension for the original MIME of the image (default: \"png\")\n * @returns {string} the file extension\n */\n getExtension() {\n const mime = this.getMIME();\n\n return MIME.getExtension(mime);\n }\n\n /**\n * Writes the image to a file\n * @param {string} path a path to the destination file\n * @param {function(Error, Jimp)} cb (optional) a function to call when the image is saved to disk\n * @returns {Jimp} this for chaining of methods\n */\n write(path, cb) {\n if (!fs || !fs.createWriteStream) {\n throw new Error(\n \"Cant access the filesystem. You can use the getBase64 method.\"\n );\n }\n\n if (typeof path !== \"string\") {\n return throwError.call(this, \"path must be a string\", cb);\n }\n\n if (typeof cb === \"undefined\") {\n cb = noop;\n }\n\n if (typeof cb !== \"function\") {\n return throwError.call(this, \"cb must be a function\", cb);\n }\n\n const mime = MIME.getType(path) || this.getMIME();\n const pathObj = Path.parse(path);\n\n if (pathObj.dir) {\n fs.mkdirSync(pathObj.dir, { recursive: true });\n }\n\n this.getBuffer(mime, (err, buffer) => {\n if (err) {\n return throwError.call(this, err, cb);\n }\n\n const stream = fs.createWriteStream(path);\n\n stream\n .on(\"open\", () => {\n stream.write(buffer);\n stream.end();\n })\n .on(\"error\", (err) => {\n return throwError.call(this, err, cb);\n });\n stream.on(\"finish\", () => {\n cb.call(this, null, this);\n });\n });\n\n return this;\n }\n\n writeAsync = (path) => promisify(this.write, this, path);\n\n /**\n * Converts the image to a base 64 string\n * @param {string} mime the mime type of the image data to be created\n * @param {function(Error, Jimp)} cb a Node-style function to call with the buffer as the second argument\n * @returns {Jimp} this for chaining of methods\n */\n getBase64(mime, cb) {\n if (mime === Jimp.AUTO) {\n // allow auto MIME detection\n mime = this.getMIME();\n }\n\n if (typeof mime !== \"string\") {\n return throwError.call(this, \"mime must be a string\", cb);\n }\n\n if (typeof cb !== \"function\") {\n return throwError.call(this, \"cb must be a function\", cb);\n }\n\n this.getBuffer(mime, function (err, data) {\n if (err) {\n return throwError.call(this, err, cb);\n }\n\n const src = \"data:\" + mime + \";base64,\" + data.toString(\"base64\");\n cb.call(this, null, src);\n });\n\n return this;\n }\n\n getBase64Async = (mime) => promisify(this.getBase64, this, mime);\n\n /**\n * Generates a perceptual hash of the image . And pads the string. Can configure base.\n * @param {number} base (optional) a number between 2 and 64 representing the base for the hash (e.g. 2 is binary, 10 is decimal, 16 is hex, 64 is base 64). Defaults to 64.\n * @param {function(Error, Jimp)} cb (optional) a callback for when complete\n * @returns {string} a string representing the hash\n */\n hash(base, cb) {\n base = base || 64;\n\n if (typeof base === \"function\") {\n cb = base;\n base = 64;\n }\n\n if (typeof base !== \"number\") {\n return throwError.call(this, \"base must be a number\", cb);\n }\n\n if (base < 2 || base > 64) {\n return throwError.call(\n this,\n \"base must be a number between 2 and 64\",\n cb\n );\n }\n\n let hash = this.pHash();\n hash = anyBase(anyBase.BIN, alphabet.slice(0, base))(hash);\n\n while (hash.length < maxHashLength[base]) {\n hash = \"0\" + hash; // pad out with leading zeros\n }\n\n if (isNodePattern(cb)) {\n cb.call(this, null, hash);\n }\n\n return hash;\n }\n\n /**\n * Calculates the perceptual hash\n * @returns {number} the perceptual hash\n */\n pHash() {\n const pHash = new ImagePHash();\n return pHash.getHash(this);\n }\n\n /**\n * Calculates the hamming distance of the current image and a hash based on their perceptual hash\n * @param {hash} compareHash hash to compare to\n * @returns {number} a number ranging from 0 to 1, 0 means they are believed to be identical\n */\n distanceFromHash(compareHash) {\n const pHash = new ImagePHash();\n const currentHash = pHash.getHash(this);\n\n return pHash.distance(currentHash, compareHash);\n }\n\n /**\n * Converts the image to a buffer\n * @param {string} mime the mime type of the image buffer to be created\n * @param {function(Error, Jimp)} cb a Node-style function to call with the buffer as the second argument\n * @returns {Jimp} this for chaining of methods\n */\n getBuffer = getBuffer;\n\n getBufferAsync = getBufferAsync;\n\n /**\n * Returns the offset of a pixel in the bitmap buffer\n * @param {number} x the x coordinate\n * @param {number} y the y coordinate\n * @param {number} edgeHandling (optional) define how to sum pixels from outside the border\n * @param {number} cb (optional) a callback for when complete\n * @returns {number} the index of the pixel or -1 if not found\n */\n getPixelIndex(x, y, edgeHandling, cb) {\n let xi;\n let yi;\n\n if (typeof edgeHandling === \"function\" && typeof cb === \"undefined\") {\n cb = edgeHandling;\n edgeHandling = null;\n }\n\n if (!edgeHandling) {\n edgeHandling = Jimp.EDGE_EXTEND;\n }\n\n if (typeof x !== \"number\" || typeof y !== \"number\") {\n return throwError.call(this, \"x and y must be numbers\", cb);\n }\n\n // round input\n x = Math.round(x);\n y = Math.round(y);\n xi = x;\n yi = y;\n\n if (edgeHandling === Jimp.EDGE_EXTEND) {\n if (x < 0) xi = 0;\n if (x >= this.bitmap.width) xi = this.bitmap.width - 1;\n if (y < 0) yi = 0;\n if (y >= this.bitmap.height) yi = this.bitmap.height - 1;\n }\n\n if (edgeHandling === Jimp.EDGE_WRAP) {\n if (x < 0) {\n xi = this.bitmap.width + x;\n }\n\n if (x >= this.bitmap.width) {\n xi = x % this.bitmap.width;\n }\n\n if (y < 0) {\n yi = this.bitmap.height + y;\n }\n\n if (y >= this.bitmap.height) {\n yi = y % this.bitmap.height;\n }\n }\n\n let i = (this.bitmap.width * yi + xi) << 2;\n\n // if out of bounds index is -1\n if (xi < 0 || xi >= this.bitmap.width) {\n i = -1;\n }\n\n if (yi < 0 || yi >= this.bitmap.height) {\n i = -1;\n }\n\n if (isNodePattern(cb)) {\n cb.call(this, null, i);\n }\n\n return i;\n }\n\n /**\n * Returns the hex colour value of a pixel\n * @param {number} x the x coordinate\n * @param {number} y the y coordinate\n * @param {function(Error, Jimp)} cb (optional) a callback for when complete\n * @returns {number} the color of the pixel\n */\n getPixelColor(x, y, cb) {\n if (typeof x !== \"number\" || typeof y !== \"number\")\n return throwError.call(this, \"x and y must be numbers\", cb);\n\n const idx = this.getPixelIndex(x, y);\n const hex = this.bitmap.data.readUInt32BE(idx);\n\n if (isNodePattern(cb)) {\n cb.call(this, null, hex);\n }\n\n return hex;\n }\n\n getPixelColour = this.getPixelColor;\n\n /**\n * Returns the hex colour value of a pixel\n * @param {number} hex color to set\n * @param {number} x the x coordinate\n * @param {number} y the y coordinate\n * @param {function(Error, Jimp)} cb (optional) a callback for when complete\n * @returns {number} the index of the pixel or -1 if not found\n */\n setPixelColor(hex, x, y, cb) {\n if (\n typeof hex !== \"number\" ||\n typeof x !== \"number\" ||\n typeof y !== \"number\"\n )\n return throwError.call(this, \"hex, x and y must be numbers\", cb);\n\n const idx = this.getPixelIndex(x, y);\n this.bitmap.data.writeUInt32BE(hex, idx);\n\n if (isNodePattern(cb)) {\n cb.call(this, null, this);\n }\n\n return this;\n }\n\n setPixelColour = this.setPixelColor;\n\n /**\n * Determine if the image contains opaque pixels.\n * @return {boolean} hasAlpha whether the image contains opaque pixels\n */\n hasAlpha() {\n const {width, height, data} = this.bitmap;\n const byteLen = (width * height) << 2;\n\n for (let idx = 3; idx < byteLen; idx += 4) {\n if (data[idx] !== 0xff) {\n return true;\n }\n }\n\n return false;\n }\n\n /**\n * Iterate scan through a region of the bitmap\n * @param {number} x the x coordinate to begin the scan at\n * @param {number} y the y coordinate to begin the scan at\n * @param w the width of the scan region\n * @param h the height of the scan region\n * @returns {IterableIterator<{x: number, y: number, idx: number, image: Jimp}>}\n */\n scanIterator(x, y, w, h) {\n if (typeof x !== \"number\" || typeof y !== \"number\") {\n return throwError.call(this, \"x and y must be numbers\");\n }\n\n if (typeof w !== \"number\" || typeof h !== \"number\") {\n return throwError.call(this, \"w and h must be numbers\");\n }\n\n return scanIterator(this, x, y, w, h);\n }\n}\n\nexport function addConstants(constants, jimpInstance = Jimp) {\n Object.entries(constants).forEach(([name, value]) => {\n jimpInstance[name] = value;\n });\n}\n\nexport function addJimpMethods(methods, jimpInstance = Jimp) {\n Object.entries(methods).forEach(([name, value]) => {\n jimpInstance.prototype[name] = value;\n });\n}\n\naddConstants(constants);\naddJimpMethods({ composite });\n\nJimp.__extraConstructors = [];\n\n/**\n * Allow client libs to add new ways to build a Jimp object.\n * @param {string} name identify the extra constructor.\n * @param {function} test a function that returns true when it accepts the arguments passed to the main constructor.\n * @param {function} run where the magic happens.\n */\nJimp.appendConstructorOption = function (name, test, run) {\n Jimp.__extraConstructors.push({ name, test, run });\n};\n\n/**\n * Read an image from a file or a Buffer. Takes the same args as the constructor\n * @returns {Promise} a promise\n */\nJimp.read = function (...args) {\n return new Promise((resolve, reject) => {\n // eslint-disable-next-line no-new\n new Jimp(...args, (err, image) => {\n if (err) reject(err);\n else resolve(image);\n });\n });\n};\n\nJimp.create = Jimp.read;\n\n/**\n * A static helper method that converts RGBA values to a single integer value\n * @param {number} r the red value (0-255)\n * @param {number} g the green value (0-255)\n * @param {number} b the blue value (0-255)\n * @param {number} a the alpha value (0-255)\n * @param {function(Error, Jimp)} cb (optional) A callback for when complete\n * @returns {number} an single integer colour value\n */\nJimp.rgbaToInt = function (r, g, b, a, cb) {\n if (\n typeof r !== \"number\" ||\n typeof g !== \"number\" ||\n typeof b !== \"number\" ||\n typeof a !== \"number\"\n ) {\n return throwError.call(this, \"r, g, b and a must be numbers\", cb);\n }\n\n if (r < 0 || r > 255) {\n return throwError.call(this, \"r must be between 0 and 255\", cb);\n }\n\n if (g < 0 || g > 255) {\n throwError.call(this, \"g must be between 0 and 255\", cb);\n }\n\n if (b < 0 || b > 255) {\n return throwError.call(this, \"b must be between 0 and 255\", cb);\n }\n\n if (a < 0 || a > 255) {\n return throwError.call(this, \"a must be between 0 and 255\", cb);\n }\n\n let i = (r & 0xff);\n i <<= 8;\n i |= (g & 0xff)\n i <<= 8;\n i |= (b & 0xff)\n i <<= 8;\n i |= (a & 0xff);\n\n // Ensure sign is correct\n i >>>= 0;\n\n if (isNodePattern(cb)) {\n cb.call(this, null, i);\n }\n\n return i;\n};\n\n/**\n * A static helper method that converts RGBA values to a single integer value\n * @param {number} i a single integer value representing an RGBA colour (e.g. 0xFF0000FF for red)\n * @param {function(Error, Jimp)} cb (optional) A callback for when complete\n * @returns {object} an object with the properties r, g, b and a representing RGBA values\n */\nJimp.intToRGBA = function (i, cb) {\n if (typeof i !== \"number\") {\n return throwError.call(this, \"i must be a number\", cb);\n }\n\n const rgba = {};\n\n rgba.r = Math.floor(i / Math.pow(256, 3));\n rgba.g = Math.floor((i - rgba.r * Math.pow(256, 3)) / Math.pow(256, 2));\n rgba.b = Math.floor(\n (i - rgba.r * Math.pow(256, 3) - rgba.g * Math.pow(256, 2)) /\n Math.pow(256, 1)\n );\n rgba.a = Math.floor(\n (i -\n rgba.r * Math.pow(256, 3) -\n rgba.g * Math.pow(256, 2) -\n rgba.b * Math.pow(256, 1)) /\n Math.pow(256, 0)\n );\n\n if (isNodePattern(cb)) {\n cb.call(this, null, rgba);\n }\n\n return rgba;\n};\n\n/**\n * Converts a css color (Hex, 8-digit (RGBA) Hex, RGB, RGBA, HSL, HSLA, HSV, HSVA, Named) to a hex number\n * @param {string} cssColor a number\n * @returns {number} a hex number representing a color\n */\nJimp.cssColorToHex = function (cssColor) {\n cssColor = cssColor || 0; // 0, null, undefined, NaN\n\n if (typeof cssColor === \"number\") return Number(cssColor);\n\n return parseInt(tinyColor(cssColor).toHex8(), 16);\n};\n\n/**\n * Limits a number to between 0 or 255\n * @param {number} n a number\n * @returns {number} the number limited to between 0 or 255\n */\nJimp.limit255 = function (n) {\n n = Math.max(n, 0);\n n = Math.min(n, 255);\n\n return n;\n};\n\n/**\n * Diffs two images and returns\n * @param {Jimp} img1 a Jimp image to compare\n * @param {Jimp} img2 a Jimp image to compare\n * @param {number} threshold (optional) a number, 0 to 1, the smaller the value the more sensitive the comparison (default: 0.1)\n * @returns {object} an object { percent: percent similar, diff: a Jimp image highlighting differences }\n */\nJimp.diff = function (img1, img2, threshold = 0.1) {\n if (!(img1 instanceof Jimp) || !(img2 instanceof Jimp))\n return throwError.call(this, \"img1 and img2 must be an Jimp images\");\n\n const bmp1 = img1.bitmap;\n const bmp2 = img2.bitmap;\n\n if (bmp1.width !== bmp2.width || bmp1.height !== bmp2.height) {\n if (bmp1.width * bmp1.height > bmp2.width * bmp2.height) {\n // img1 is bigger\n img1 = img1.cloneQuiet().resize(bmp2.width, bmp2.height);\n } else {\n // img2 is bigger (or they are the same in area)\n img2 = img2.cloneQuiet().resize(bmp1.width, bmp1.height);\n }\n }\n\n if (typeof threshold !== \"number\" || threshold < 0 || threshold > 1) {\n return throwError.call(this, \"threshold must be a number between 0 and 1\");\n }\n\n const diff = new Jimp(bmp1.width, bmp1.height, 0xffffffff);\n\n const numDiffPixels = pixelMatch(\n bmp1.data,\n bmp2.data,\n diff.bitmap.data,\n diff.bitmap.width,\n diff.bitmap.height,\n { threshold }\n );\n\n return {\n percent: numDiffPixels / (diff.bitmap.width * diff.bitmap.height),\n image: diff,\n };\n};\n\n/**\n * Calculates the hamming distance of two images based on their perceptual hash\n * @param {Jimp} img1 a Jimp image to compare\n * @param {Jimp} img2 a Jimp image to compare\n * @returns {number} a number ranging from 0 to 1, 0 means they are believed to be identical\n */\nJimp.distance = function (img1, img2) {\n const phash = new ImagePHash();\n const hash1 = phash.getHash(img1);\n const hash2 = phash.getHash(img2);\n\n return phash.distance(hash1, hash2);\n};\n\n/**\n * Calculates the hamming distance of two images based on their perceptual hash\n * @param {hash} hash1 a pHash\n * @param {hash} hash2 a pHash\n * @returns {number} a number ranging from 0 to 1, 0 means they are believed to be identical\n */\nJimp.compareHashes = function (hash1, hash2) {\n const phash = new ImagePHash();\n\n return phash.distance(hash1, hash2);\n};\n\n/**\n * Compute color difference\n * 0 means no difference, 1 means maximum difference.\n * @param {number} rgba1: first color to compare.\n * @param {number} rgba2: second color to compare.\n * Both parameters must be an color object {r:val, g:val, b:val, a:val}\n * Where `a` is optional and `val` is an integer between 0 and 255.\n * @returns {number} float between 0 and 1.\n */\nJimp.colorDiff = function (rgba1, rgba2) {\n const pow = (n) => Math.pow(n, 2);\n const { max } = Math;\n const maxVal = 255 * 255 * 3;\n\n if (rgba1.a !== 0 && !rgba1.a) {\n rgba1.a = 255;\n }\n\n if (rgba2.a !== 0 && !rgba2.a) {\n rgba2.a = 255;\n }\n\n return (\n (max(pow(rgba1.r - rgba2.r), pow(rgba1.r - rgba2.r - rgba1.a + rgba2.a)) +\n max(pow(rgba1.g - rgba2.g), pow(rgba1.g - rgba2.g - rgba1.a + rgba2.a)) +\n max(pow(rgba1.b - rgba2.b), pow(rgba1.b - rgba2.b - rgba1.a + rgba2.a))) /\n maxVal\n );\n};\n\n/**\n * Helper to create Jimp methods that emit events before and after its execution.\n * @param {string} methodName The name to be appended to Jimp prototype.\n * @param {string} evName The event name to be called.\n * It will be prefixed by `before-` and emitted when on method call.\n * It will be appended by `ed` and emitted after the method run.\n * @param {function} method A function implementing the method itself.\n * It will also create a quiet version that will not emit events, to not\n * mess the user code with many `changed` event calls. You can call with\n * `methodName + \"Quiet\"`.\n *\n * The emitted event comes with a object parameter to the listener with the\n * `methodName` as one attribute.\n */\nexport function jimpEvMethod(methodName, evName, method) {\n const evNameBefore = \"before-\" + evName;\n const evNameAfter = evName.replace(/e$/, \"\") + \"ed\";\n\n Jimp.prototype[methodName] = function (...args) {\n let wrappedCb;\n const cb = args[method.length - 1];\n const jimpInstance = this;\n\n if (typeof cb === \"function\") {\n wrappedCb = function (...args) {\n const [err, data] = args;\n\n if (err) {\n jimpInstance.emitError(methodName, err);\n } else {\n jimpInstance.emitMulti(methodName, evNameAfter, {\n [methodName]: data,\n });\n }\n\n cb.apply(this, args);\n };\n\n args[args.length - 1] = wrappedCb;\n } else {\n wrappedCb = false;\n }\n\n this.emitMulti(methodName, evNameBefore);\n\n let result;\n\n try {\n result = method.apply(this, args);\n\n if (!wrappedCb) {\n this.emitMulti(methodName, evNameAfter, {\n [methodName]: result,\n });\n }\n } catch (error) {\n error.methodName = methodName;\n this.emitError(methodName, error);\n }\n\n return result;\n };\n\n Jimp.prototype[methodName + \"Quiet\"] = method;\n}\n\n/**\n * Creates a new image that is a clone of this one.\n * @param {function(Error, Jimp)} cb (optional) A callback for when complete\n * @returns the new image\n */\njimpEvMethod(\"clone\", \"clone\", function (cb) {\n const clone = new Jimp(this);\n\n if (isNodePattern(cb)) {\n cb.call(clone, null, clone);\n }\n\n return clone;\n});\n\n/**\n * Simplify jimpEvMethod call for the common `change` evName.\n * @param {string} methodName name of the method\n * @param {function} method to watch changes for\n */\nexport function jimpEvChange(methodName, method) {\n jimpEvMethod(methodName, \"change\", method);\n}\n\n/**\n * Sets the type of the image (RGB or RGBA) when saving as PNG format (default is RGBA)\n * @param b A Boolean, true to use RGBA or false to use RGB\n * @param {function(Error, Jimp)} cb (optional) a callback for when complete\n * @returns {Jimp} this for chaining of methods\n */\njimpEvChange(\"background\", function (hex, cb) {\n if (typeof hex !== \"number\") {\n return throwError.call(this, \"hex must be a hexadecimal rgba value\", cb);\n }\n\n this._background = hex;\n\n if (isNodePattern(cb)) {\n cb.call(this, null, this);\n }\n\n return this;\n});\n\n/**\n * Scans through a region of the bitmap, calling a function for each pixel.\n * @param {number} x the x coordinate to begin the scan at\n * @param {number} y the y coordinate to begin the scan at\n * @param w the width of the scan region\n * @param h the height of the scan region\n * @param f a function to call on even pixel; the (x, y) position of the pixel\n * and the index of the pixel in the bitmap buffer are passed to the function\n * @param {function(Error, Jimp)} cb (optional) a callback for when complete\n * @returns {Jimp} this for chaining of methods\n */\njimpEvChange(\"scan\", function (x, y, w, h, f, cb) {\n if (typeof x !== \"number\" || typeof y !== \"number\") {\n return throwError.call(this, \"x and y must be numbers\", cb);\n }\n\n if (typeof w !== \"number\" || typeof h !== \"number\") {\n return throwError.call(this, \"w and h must be numbers\", cb);\n }\n\n if (typeof f !== \"function\") {\n return throwError.call(this, \"f must be a function\", cb);\n }\n\n const result = scan(this, x, y, w, h, f);\n\n if (isNodePattern(cb)) {\n cb.call(this, null, result);\n }\n\n return result;\n});\n\nif (process.env.ENVIRONMENT === \"BROWSER\") {\n // For use in a web browser or web worker\n /* global self */\n let gl;\n\n if (typeof window !== \"undefined\" && typeof window === \"object\") {\n gl = window;\n }\n\n if (typeof self !== \"undefined\" && typeof self === \"object\") {\n gl = self;\n }\n\n gl.Jimp = Jimp;\n gl.Buffer = Buffer;\n}\n\nexport { addType } from \"./utils/mime\";\n\nexport default Jimp;\n"],"mappings":";;;AAAA,OAAOA,EAAE,MAAM,IAAI;AACnB,OAAOC,IAAI,MAAM,MAAM;AACvB,OAAOC,YAAY,MAAM,QAAQ;AAEjC,SAASC,aAAa,EAAEC,UAAU,EAAEC,IAAI,EAAEC,YAAY,QAAQ,aAAa;AAC3E,OAAOC,OAAO,MAAM,UAAU;AAC9B,OAAOC,UAAU,MAAM,YAAY;AACnC,OAAOC,SAAS,MAAM,YAAY;AAElC,OAAOC,UAAU,MAAM,iBAAiB;AACxC,OAAOC,OAAO,MAAM,WAAW;AAE/B,OAAOC,SAAS,MAAM,aAAa;AACnC,OAAOC,SAAS,MAAM,mBAAmB;AACzC,OAAO,KAAKC,IAAI,MAAM,cAAc;AACpC,SAASC,WAAW,EAAEC,SAAS,EAAEC,cAAc,QAAQ,sBAAsB;AAC7E,OAAO,KAAKC,SAAS,MAAM,aAAa;AAExC,MAAMC,QAAQ,GACZ,kEAAkE;;AAEpE;AACA;AACA,MAAMC,aAAa,GAAG,CAACC,GAAG,EAAEA,GAAG,CAAC;AAEhC,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAG,EAAE,EAAEA,CAAC,EAAE,EAAE;EAC3B,MAAMC,OAAO,GAAGhB,OAAO,CACrBA,OAAO,CAACiB,GAAG,EACXL,QAAQ,CAACM,KAAK,CAAC,CAAC,EAAEH,CAAC,CAAC,CACrB,CAAC,IAAII,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC,CAACC,IAAI,CAA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