chore: add jimp dependency, icon padding script, and update configuration

This commit is contained in:
2026-05-31 14:04:37 +02:00
parent 30f81045ac
commit 7cd17307ba
1126 changed files with 166400 additions and 2 deletions
+53
View File
@@ -0,0 +1,53 @@
import { isNodePattern, throwError } from "@jimp/utils";
export default (() => ({
/**
* Uniformly scales the image by a factor.
* @param {number} f the factor to scale the image by
* @param {string} mode (optional) a scaling method (e.g. Jimp.RESIZE_BEZIER)
* @param {function(Error, Jimp)} cb (optional) a callback for when complete
* @returns {Jimp} this for chaining of methods
*/
scale(f, mode, cb) {
if (typeof f !== "number") {
return throwError.call(this, "f must be a number", cb);
}
if (f < 0) {
return throwError.call(this, "f must be a positive number", cb);
}
if (typeof mode === "function" && typeof cb === "undefined") {
cb = mode;
mode = null;
}
const w = this.bitmap.width * f;
const h = this.bitmap.height * f;
this.resize(w, h, mode);
if (isNodePattern(cb)) {
cb.call(this, null, this);
}
return this;
},
/**
* Scale the image to the largest size that fits inside the rectangle that has the given width and height.
* @param {number} w the width to resize the image to
* @param {number} h the height to resize the image to
* @param {string} mode (optional) a scaling method (e.g. Jimp.RESIZE_BEZIER)
* @param {function(Error, Jimp)} cb (optional) a callback for when complete
* @returns {Jimp} this for chaining of methods
*/
scaleToFit(w, h, mode, cb) {
if (typeof w !== "number" || typeof h !== "number") {
return throwError.call(this, "w and h must be numbers", cb);
}
if (typeof mode === "function" && typeof cb === "undefined") {
cb = mode;
mode = null;
}
const f = w / h > this.bitmap.width / this.bitmap.height ? h / this.bitmap.height : w / this.bitmap.width;
this.scale(f, mode);
if (isNodePattern(cb)) {
cb.call(this, null, this);
}
return this;
}
}));
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.js","names":["isNodePattern","throwError","scale","f","mode","cb","call","w","bitmap","width","h","height","resize","scaleToFit"],"sources":["../src/index.js"],"sourcesContent":["import { isNodePattern, throwError } from \"@jimp/utils\";\n\nexport default () => ({\n /**\n * Uniformly scales the image by a factor.\n * @param {number} f the factor to scale the image by\n * @param {string} mode (optional) a scaling method (e.g. Jimp.RESIZE_BEZIER)\n * @param {function(Error, Jimp)} cb (optional) a callback for when complete\n * @returns {Jimp} this for chaining of methods\n */\n scale(f, mode, cb) {\n if (typeof f !== \"number\") {\n return throwError.call(this, \"f must be a number\", cb);\n }\n\n if (f < 0) {\n return throwError.call(this, \"f must be a positive number\", cb);\n }\n\n if (typeof mode === \"function\" && typeof cb === \"undefined\") {\n cb = mode;\n mode = null;\n }\n\n const w = this.bitmap.width * f;\n const h = this.bitmap.height * f;\n this.resize(w, h, mode);\n\n if (isNodePattern(cb)) {\n cb.call(this, null, this);\n }\n\n return this;\n },\n\n /**\n * Scale the image to the largest size that fits inside the rectangle that has the given width and height.\n * @param {number} w the width to resize the image to\n * @param {number} h the height to resize the image to\n * @param {string} mode (optional) a scaling method (e.g. Jimp.RESIZE_BEZIER)\n * @param {function(Error, Jimp)} cb (optional) a callback for when complete\n * @returns {Jimp} this for chaining of methods\n */\n scaleToFit(w, h, mode, cb) {\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 mode === \"function\" && typeof cb === \"undefined\") {\n cb = mode;\n mode = null;\n }\n\n const f =\n w / h > this.bitmap.width / this.bitmap.height\n ? h / this.bitmap.height\n : w / this.bitmap.width;\n this.scale(f, mode);\n\n if (isNodePattern(cb)) {\n cb.call(this, null, this);\n }\n\n return this;\n },\n});\n"],"mappings":"AAAA,SAASA,aAAa,EAAEC,UAAU,QAAQ,aAAa;AAEvD,gBAAe,OAAO;EACpB;AACF;AACA;AACA;AACA;AACA;AACA;EACEC,KAAK,CAACC,CAAC,EAAEC,IAAI,EAAEC,EAAE,EAAE;IACjB,IAAI,OAAOF,CAAC,KAAK,QAAQ,EAAE;MACzB,OAAOF,UAAU,CAACK,IAAI,CAAC,IAAI,EAAE,oBAAoB,EAAED,EAAE,CAAC;IACxD;IAEA,IAAIF,CAAC,GAAG,CAAC,EAAE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