1 line
2.5 KiB
Plaintext
1 line
2.5 KiB
Plaintext
{"version":3,"sources":["../src/index.js"],"names":["JPEG","throwError","isNodePattern","MIME_TYPE","mime","constants","MIME_JPEG","decoders","decode","encoders","image","encode","bitmap","_quality","data","class","quality","n","cb","call","Math","round"],"mappings":";;AAAA,OAAOA,IAAP,MAAiB,SAAjB;AACA,SAASC,UAAT,EAAqBC,aAArB,QAA0C,aAA1C;AAEA,IAAMC,SAAS,GAAG,YAAlB;AAEA,gBAAe;AAAA,SAAO;AACpBC,IAAAA,IAAI,sBAAKD,SAAL,EAAiB,CAAC,MAAD,EAAS,KAAT,EAAgB,KAAhB,CAAjB,CADgB;AAGpBE,IAAAA,SAAS,EAAE;AACTC,MAAAA,SAAS,EAAEH;AADF,KAHS;AAOpBI,IAAAA,QAAQ,sBACLJ,SADK,EACOH,IAAI,CAACQ,MADZ,CAPY;AAWpBC,IAAAA,QAAQ,sBACLN,SADK,EACO,UAAAO,KAAK;AAAA,aAAIV,IAAI,CAACW,MAAL,CAAYD,KAAK,CAACE,MAAlB,EAA0BF,KAAK,CAACG,QAAhC,EAA0CC,IAA9C;AAAA,KADZ,CAXY;AAepBC,IAAAA,KAAK,EAAE;AACL;AACAF,MAAAA,QAAQ,EAAE,GAFL;;AAGL;;;;;;AAMAG,MAAAA,OATK,mBASGC,CATH,EASMC,EATN,EASU;AACb,YAAI,OAAOD,CAAP,KAAa,QAAjB,EAA2B;AACzB,iBAAOhB,UAAU,CAACkB,IAAX,CAAgB,IAAhB,EAAsB,oBAAtB,EAA4CD,EAA5C,CAAP;AACD;;AAED,YAAID,CAAC,GAAG,CAAJ,IAASA,CAAC,GAAG,GAAjB,EAAsB;AACpB,iBAAOhB,UAAU,CAACkB,IAAX,CAAgB,IAAhB,EAAsB,4BAAtB,EAAoDD,EAApD,CAAP;AACD;;AAED,aAAKL,QAAL,GAAgBO,IAAI,CAACC,KAAL,CAAWJ,CAAX,CAAhB;;AAEA,YAAIf,aAAa,CAACgB,EAAD,CAAjB,EAAuB;AACrBA,UAAAA,EAAE,CAACC,IAAH,CAAQ,IAAR,EAAc,IAAd,EAAoB,IAApB;AACD;;AAED,eAAO,IAAP;AACD;AAzBI;AAfa,GAAP;AAAA,CAAf","sourcesContent":["import JPEG from 'jpeg-js';\nimport { throwError, isNodePattern } from '@jimp/utils';\n\nconst MIME_TYPE = 'image/jpeg';\n\nexport default () => ({\n mime: { [MIME_TYPE]: ['jpeg', 'jpg', 'jpe'] },\n\n constants: {\n MIME_JPEG: MIME_TYPE\n },\n\n decoders: {\n [MIME_TYPE]: JPEG.decode\n },\n\n encoders: {\n [MIME_TYPE]: image => JPEG.encode(image.bitmap, image._quality).data\n },\n\n class: {\n // The quality to be used when saving JPEG images\n _quality: 100,\n /**\n * Sets the quality of the image when saving as JPEG format (default is 100)\n * @param {number} n The quality to use 0-100\n * @param {function(Error, Jimp)} cb (optional) a callback for when complete\n * @returns {Jimp} this for chaining of methods\n */\n quality(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"],"file":"index.js"} |