@pi-r/jimp 0.3.2 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +1 -1
- package/index.js +76 -78
- package/package.json +3 -3
package/LICENSE
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Copyright 2023 Studio
|
|
1
|
+
Copyright 2023 Wit Studio
|
|
2
2
|
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
4
|
|
package/README.md
CHANGED
package/index.js
CHANGED
|
@@ -282,32 +282,31 @@ class JimpHandler {
|
|
|
282
282
|
return;
|
|
283
283
|
}
|
|
284
284
|
const data = this.instance.methodData;
|
|
285
|
-
if (
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
285
|
+
if (data) {
|
|
286
|
+
const handler = this.handler;
|
|
287
|
+
for (const [name, args = []] of data) {
|
|
288
|
+
try {
|
|
289
|
+
const alias = getMethodName(name);
|
|
290
|
+
if (!alias) {
|
|
291
|
+
throw (0, types_1.errorValue)("Invalid method name", name);
|
|
292
|
+
}
|
|
293
|
+
if (alias === 'composite') {
|
|
294
|
+
const [src, x, y, opts] = args;
|
|
295
|
+
if ((0, types_1.isString)(src) && typeof x === 'number' && typeof y === 'number') {
|
|
296
|
+
handler.composite(await jimp.read(src), x, y, opts);
|
|
297
|
+
}
|
|
298
|
+
else {
|
|
299
|
+
throw (0, types_1.errorValue)("Invalid parameters", alias);
|
|
300
|
+
}
|
|
299
301
|
}
|
|
300
302
|
else {
|
|
301
|
-
|
|
303
|
+
handler[alias](...args);
|
|
302
304
|
}
|
|
303
305
|
}
|
|
304
|
-
|
|
305
|
-
|
|
306
|
+
catch (err) {
|
|
307
|
+
this.instance.writeFail(["Unknown", "jimp" + ': ' + name], err, 2048);
|
|
306
308
|
}
|
|
307
309
|
}
|
|
308
|
-
catch (err) {
|
|
309
|
-
this.instance.writeFail(["Unknown", "jimp" + ': ' + name], err, 2048);
|
|
310
|
-
}
|
|
311
310
|
}
|
|
312
311
|
}
|
|
313
312
|
resize() {
|
|
@@ -315,64 +314,63 @@ class JimpHandler {
|
|
|
315
314
|
return;
|
|
316
315
|
}
|
|
317
316
|
const data = this.instance.resizeData;
|
|
318
|
-
if (
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
break;
|
|
317
|
+
if (data) {
|
|
318
|
+
const { width, height, color, algorithm, align, mode } = data;
|
|
319
|
+
const handler = this.handler;
|
|
320
|
+
if (!isNaN(color)) {
|
|
321
|
+
handler.background(color);
|
|
322
|
+
}
|
|
323
|
+
let resizeMode = jimp.RESIZE_NEAREST_NEIGHBOR, flags = 0;
|
|
324
|
+
switch (algorithm) {
|
|
325
|
+
case 'bilinear':
|
|
326
|
+
resizeMode = jimp.RESIZE_BILINEAR;
|
|
327
|
+
break;
|
|
328
|
+
case 'bicubic':
|
|
329
|
+
resizeMode = jimp.RESIZE_BICUBIC;
|
|
330
|
+
break;
|
|
331
|
+
case 'hermite':
|
|
332
|
+
resizeMode = jimp.RESIZE_HERMITE;
|
|
333
|
+
break;
|
|
334
|
+
case 'bezier':
|
|
335
|
+
resizeMode = jimp.RESIZE_BEZIER;
|
|
336
|
+
break;
|
|
337
|
+
}
|
|
338
|
+
switch (align[0]) {
|
|
339
|
+
case 'left':
|
|
340
|
+
flags |= jimp.HORIZONTAL_ALIGN_LEFT;
|
|
341
|
+
break;
|
|
342
|
+
case 'center':
|
|
343
|
+
flags |= jimp.HORIZONTAL_ALIGN_CENTER;
|
|
344
|
+
break;
|
|
345
|
+
case 'right':
|
|
346
|
+
flags |= jimp.HORIZONTAL_ALIGN_RIGHT;
|
|
347
|
+
break;
|
|
348
|
+
}
|
|
349
|
+
switch (align[1]) {
|
|
350
|
+
case 'top':
|
|
351
|
+
flags |= jimp.VERTICAL_ALIGN_TOP;
|
|
352
|
+
break;
|
|
353
|
+
case 'middle':
|
|
354
|
+
flags |= jimp.VERTICAL_ALIGN_MIDDLE;
|
|
355
|
+
break;
|
|
356
|
+
case 'bottom':
|
|
357
|
+
flags |= jimp.VERTICAL_ALIGN_BOTTOM;
|
|
358
|
+
break;
|
|
359
|
+
}
|
|
360
|
+
switch (mode) {
|
|
361
|
+
case 'contain':
|
|
362
|
+
handler.contain(width, height, flags);
|
|
363
|
+
break;
|
|
364
|
+
case 'cover':
|
|
365
|
+
handler.cover(width, height, flags);
|
|
366
|
+
break;
|
|
367
|
+
case 'scale':
|
|
368
|
+
handler.scaleToFit(width, height);
|
|
369
|
+
break;
|
|
370
|
+
default:
|
|
371
|
+
handler.resize(width === Infinity ? jimp.AUTO : width, height === Infinity ? jimp.AUTO : height, resizeMode);
|
|
372
|
+
break;
|
|
373
|
+
}
|
|
376
374
|
}
|
|
377
375
|
}
|
|
378
376
|
background(value) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-r/jimp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"description": "Jimp image constructor for E-mc.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"publishConfig": {
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"homepage": "https://github.com/anpham6/pi-r#readme",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@e-mc/image": "^0.
|
|
24
|
-
"@e-mc/types": "^0.
|
|
23
|
+
"@e-mc/image": "^0.7.2",
|
|
24
|
+
"@e-mc/types": "^0.7.2",
|
|
25
25
|
"bmp-js": "^0.1.0",
|
|
26
26
|
"gifwrap": "^0.10.1",
|
|
27
27
|
"jimp": "^0.22.12"
|