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EAAI,OAAgB,CACvB,GAAI,QAAQ,GACX,IAAK,IAAI,EAAI,EAAG,EAAI,EAAO,OAAQ,IAClC,EAAI,GAAK,EAAO,GAAK,SAItB,EAAI,IAAI,GAGT,OAAO,CACR,CAGA,GAAI,UAAU,GAAM,CAEnB,IADA,IAAI,EAAI,EACC,EAAI,EAAG,EAAI,EAAE,MAAO,IAC5B,IAAK,IAAI,EAAI,EAAG,EAAI,EAAE,OAAQ,IAC7B,EAAI,IAAI,EAAG,EAAG,EAAG,EAAO,MACxB,EAAI,IAAI,EAAG,EAAG,EAAG,EAAO,MACxB,EAAI,IAAI,EAAG,EAAG,EAAG,EAAO,MACxB,EAAI,IAAI,EAAG,EAAG,EAAG,EAAO,MAG1B,OAAO,CACR,CAGA,GAAI,EAAK,CACR,GAAI,EAAI,OACP,GAAI,EAAI,QAAU,EAAE,MAAO,MAAM,MAAM,qBAAuB,EAAI,MAAQ,mCAAqC,EAAE,YAE7G,EAAI,MAAQ,EAAE,MACnB,GAAI,EAAI,QACP,GAAI,EAAI,SAAW,EAAE,OAAQ,MAAM,MAAM,sBAAwB,EAAI,OAAS,oCAAsC,EAAE,aAElH,EAAI,OAAS,EAAE,OAKpB,OAHI,EAAI,MAAQ,EAAI,KAAK,IAAK,EAAI,KAAK,IAAI,GACtC,EAAI,KAAO,EAET,CACR,CACD,EAWA,IAAI,MAAQ,CACX,IAAO,YACP,YAAa,YACb,IAAO,YACP,YAAa,YACb,aAAc,aACd,YAAa,aACb,IAAO,aACP,KAAQ,aACR,IAAO,YACP,YAAa,YACb,eAAgB,YAChB,KAAQ,aACR,IAAO,aACP,KAAQ,aACR,YAAa,aACb,aAAc","file":"/npm/image-output@2.4.2/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/image-output@2.4.2/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","// save pixel data into a file\r\n'use strict'\r\n\r\nvar saveFile = require('save-file')\r\nvar encode = require('image-encode')\r\nvar pxls = require('pxls')\r\nvar isFloat = require('is-float-array')\r\nvar ext = require('get-ext')\r\nvar isBuffer = require('is-buffer')\r\nvar toConsole = require('./console')\r\nvar toab = require('to-array-buffer')\r\nvar isStream = require('is-stream')\r\nvar isBrowser = require('is-browser')\r\nvar isBlob = require('is-blob')\r\nvar isObj = require('is-plain-obj')\r\n\r\nvar context\r\n\r\nmodule.exports = function output (data, dst, o) {\r\n\t// swap dst/o\r\n\tif ((isObj(dst) || typeof dst === 'string' || Array.isArray(dst)) && o && !isObj(o)) {\r\n\t\tvar t = dst\r\n\t\tdst = o\r\n\t\to = t\r\n\t}\r\n\r\n\tif (!dst) dst = console\r\n\r\n\tif (typeof o === 'string') o = {mime: o}\r\n\telse if (Array.isArray(o)) o = {shape: o}\r\n\telse if (!o) o = {}\r\n\r\n\t// TODO: add shortcuts here for encoded png → png, array → array, canvas → canvas saves\r\n\r\n\to.type = o.type || o.mime || o.mimeType || o.format || (typeof dst === 'string' && types[ext(dst).slice(1)]) || types.png\r\n\to.quality = o.quality || null\r\n\r\n\t// handle promise\r\n\tif (data.then) {\r\n\t\treturn data.then(function (result) {\r\n\t\t\t\treturn output(result, dst, o)\r\n\t\t})\r\n\t}\r\n\r\n\t// unwrap internals\r\n\tif (data.canvas) data = data.canvas\r\n\tif (data.gl || data._gl || data.regl) data = data.regl ? data.regl._gl : data.gl || data._gl\r\n\r\n\t// figure out width/height\r\n\tif (o.shape) o.width = o.shape[0], o.height = o.shape[1]\r\n\tif (!o.width) o.width = data.shape ? data.shape[0] : data.width || data.drawingBufferWidth\r\n\tif (!o.height) o.height = data.shape ? data.shape[1] : data.height || data.drawingBufferHeight\r\n\tif (!o.width || !o.height) {\r\n\t\tthrow new Error('Options must define `width` and `height`')\r\n\t}\r\n\r\n\tvar pixels = pxls(data, [o.width, o.height])\r\n\r\n\t// save to a file\r\n\tif (typeof dst === 'string') {\r\n\t\treturn saveFile.saveSync(encode(pixels, o), dst)\r\n\t}\r\n\r\n\t// console, stdout\r\n\tif (dst === toConsole.stdout || dst === console) {\r\n\t\treturn toConsole(pixels, o)\r\n\t}\r\n\r\n\t// document\r\n\tif (!dst.getContext && (dst.createElement || dst.appendChild)) {\r\n\t\tvar container = (dst.appendChild && dst.ownerDocument) ? dst : dst.body || dst.documentElement\r\n\t\tvar canvas = (dst.createElement ? dst : dst.ownerDocument).createElement('canvas')\r\n\t\tdst = container.appendChild(canvas)\r\n\t}\r\n\r\n\t// canvas2d, context\r\n\tif (dst.getContext) {\r\n\t\tdst = dst.getContext('2d')\r\n\t\tif (!dst) throw Error('Only Canvas2D context is supported')\r\n\t}\r\n\tif (dst.canvas) {\r\n\t\tvar ctx = dst\r\n\r\n\t\tctx.canvas.width = o.width\r\n\t\tctx.canvas.height = o.height\r\n\t\tif (pixels) {\r\n\t\t\tvar idata = ctx.createImageData(o.width, o.height)\r\n\t\t\tidata.data.set(pixels)\r\n\t\t\tctx.putImageData(idata, 0, 0)\r\n\t\t}\r\n\t\telse {\r\n\t\t\tctx.drawImage(data)\r\n\t\t}\r\n\r\n\t\treturn idata\r\n\t}\r\n\r\n\t// Stream\r\n\tif (isStream(dst)) {\r\n\t\tif (!dst.write) throw Error('Only writable streams are supported')\r\n\t\tvar data = encode(pixels, o)\r\n\t\tdst.write(new Uint8Array(data))\r\n\t\tdst.on('error', function (e) {\r\n\t\t\tthrow e\r\n\t\t})\r\n\t\treturn data\r\n\t}\r\n\r\n\t// function\r\n\tif (typeof dst === 'function') {\r\n\t\tvar data = {data: pixels, width: o.width, height: o.height}\r\n\t\treturn dst(data) || data\r\n\t}\r\n\r\n\t// ArrayBuffer\r\n\tif (dst instanceof ArrayBuffer) {\r\n\t\tdst = new Uint8Array(dst)\r\n\t}\r\n\r\n\t// Array, TypedArray, Buffer\r\n\tif (dst.length != null) {\r\n\t\tif (isFloat(dst)) {\r\n\t\t\tfor (let i = 0; i < pixels.length; i++) {\r\n\t\t\t\tdst[i] = pixels[i] / 255\r\n\t\t\t}\r\n\t\t}\r\n\t\telse {\r\n\t\t\tdst.set(pixels)\r\n\t\t}\r\n\r\n\t\treturn dst\r\n\t}\r\n\r\n\t// ndarray\r\n\tif (isNdarray(dst)) {\r\n\t\tvar i = 0\r\n\t\tfor (var x = 0; x < o.width; x++) {\r\n\t\t\tfor (var y = 0; y < o.height; y++) {\r\n\t\t\t\tdst.set(x, y, 0, pixels[i++])\r\n\t\t\t\tdst.set(x, y, 1, pixels[i++])\r\n\t\t\t\tdst.set(x, y, 2, pixels[i++])\r\n\t\t\t\tdst.set(x, y, 3, pixels[i++])\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn dst\r\n\t}\r\n\r\n\t// ImageData, rest of objects\r\n\tif (dst) {\r\n\t\tif (dst.width) {\r\n\t\t\tif (dst.width !== o.width) throw Error('Destination width ' + dst.width + ' is different from pixels width ' + o.width)\r\n\t\t}\r\n\t\telse dst.width = o.width\r\n\t\tif (dst.height) {\r\n\t\t\tif (dst.height !== o.height) throw Error('Destination height ' + dst.height + ' is different from pixels height ' + o.height)\r\n\t\t}\r\n\t\telse dst.height = o.height\r\n\r\n\t\tif (dst.data && dst.data.set) dst.data.set(pixels)\r\n\t\telse dst.data = pixels\r\n\r\n\t\treturn dst\r\n\t}\r\n}\r\n\r\nfunction isNdarray(v) {\r\n  return v &&\r\n      v.shape &&\r\n      v.stride &&\r\n      v.offset != null &&\r\n      v.dtype\r\n}\r\n\r\n\r\nvar types = {\r\n\t'png': 'image/png',\r\n\t'image/png': 'image/png',\r\n\t'gif': 'image/gif',\r\n\t'image/gif': 'image/gif',\r\n\t'image/jpeg': 'image/jpeg',\r\n\t'image/jpg': 'image/jpeg',\r\n\t'jpg': 'image/jpeg',\r\n\t'jpeg': 'image/jpeg',\r\n\t'bmp': 'image/bmp',\r\n\t'image/bmp': 'image/bmp',\r\n\t'image/bitmap': 'image/bmp',\r\n\t'tiff': 'image/tiff',\r\n\t'tif': 'image/tiff',\r\n\t'exif': 'image/tiff',\r\n\t'image/tif': 'image/tiff',\r\n\t'image/tiff': 'image/tiff'\r\n}\r\n"]}