chore: add jimp dependency, icon padding script, and update configuration
This commit is contained in:
+41
@@ -0,0 +1,41 @@
|
||||
import JPEG from "jpeg-js";
|
||||
import { throwError, isNodePattern } from "@jimp/utils";
|
||||
const MIME_TYPE = "image/jpeg";
|
||||
export default (() => ({
|
||||
mime: {
|
||||
[MIME_TYPE]: ["jpeg", "jpg", "jpe"]
|
||||
},
|
||||
constants: {
|
||||
MIME_JPEG: MIME_TYPE
|
||||
},
|
||||
decoders: {
|
||||
[MIME_TYPE]: JPEG.decode
|
||||
},
|
||||
encoders: {
|
||||
[MIME_TYPE]: image => JPEG.encode(image.bitmap, image._quality).data
|
||||
},
|
||||
class: {
|
||||
// The quality to be used when saving JPEG images
|
||||
_quality: 100,
|
||||
/**
|
||||
* Sets the quality of the image when saving as JPEG format (default is 100)
|
||||
* @param {number} n The quality to use 0-100
|
||||
* @param {function(Error, Jimp)} cb (optional) a callback for when complete
|
||||
* @returns {Jimp} this for chaining of methods
|
||||
*/
|
||||
quality(n, cb) {
|
||||
if (typeof n !== "number") {
|
||||
return throwError.call(this, "n must be a number", cb);
|
||||
}
|
||||
if (n < 0 || n > 100) {
|
||||
return throwError.call(this, "n must be a number 0 - 100", cb);
|
||||
}
|
||||
this._quality = Math.round(n);
|
||||
if (isNodePattern(cb)) {
|
||||
cb.call(this, null, this);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}));
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"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"],"sources":["../src/index.js"],"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"],"mappings":"AAAA,OAAOA,IAAI,MAAM,SAAS;AAC1B,SAASC,UAAU,EAAEC,aAAa,QAAQ,aAAa;AAEvD,MAAMC,SAAS,GAAG,YAAY;AAE9B,gBAAe,OAAO;EACpBC,IAAI,EAAE;IAAE,CAACD,SAAS,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK;EAAE,CAAC;EAE7CE,SAAS,EAAE;IACTC,SAAS,EAAEH;EACb,CAAC;EAEDI,QAAQ,EAAE;IACR,CAACJ,SAAS,GAAGH,IAAI,CAACQ;EACpB,CAAC;EAEDC,QAAQ,EAAE;IACR,CAACN,SAAS,GAAIO,KAAK,IAAKV,IAAI,CAACW,MAAM,CAACD,KAAK,CAACE,MAAM,EAAEF,KAAK,CAACG,QAAQ,CAAC,CAACC;EACpE,CAAC;EAEDC,KAAK,EAAE;IACL;IACAF,QAAQ,EAAE,GAAG;IACb;AACJ;AACA;AACA;AACA;AACA;IACIG,OAAO,CAACC,CAAC,EAAEC,EAAE,EAAE;MACb,IAAI,OAAOD,CAAC,KAAK,QAAQ,EAAE;QACzB,OAAOhB,UAAU,CAACkB,IAAI,CAAC,IAAI,EAAE,oBAAoB,EAAED,EAAE,CAAC;MACxD;MAEA,IAAID,CAAC,GAAG,CAAC,IAAIA,CAAC,GAAG,GAAG,EAAE;QACpB,OAAOhB,UAAU,CAACkB,IAAI,CAAC,IAAI,EAAE,4BAA4B,EAAED,EAAE,CAAC;MAChE;MAEA,IAAI,CAACL,QAAQ,GAAGO,IAAI,CAACC,KAAK,CAACJ,CAAC,CAAC;MAE7B,IAAIf,aAAa,CAACgB,EAAE,CAAC,EAAE;QACrBA,EAAE,CAACC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC;MAC3B;MAEA,OAAO,IAAI;IACb;EACF;AACF,CAAC,CAAC"}
|
||||
Reference in New Issue
Block a user