@pi-r/jimp 0.11.0 → 0.11.1
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/index.js +1 -1
- package/package.json +4 -4
- package/worker/jimp.js +19 -7
package/index.js
CHANGED
|
@@ -800,7 +800,7 @@ class Jimp extends Image {
|
|
|
800
800
|
}
|
|
801
801
|
if (method) {
|
|
802
802
|
const values = method.map(item => [getMethodName(item[0]) || item[0], item[1]]);
|
|
803
|
-
if (values.find(item => !item[0]
|
|
803
|
+
if (values.find(item => !item[0])) {
|
|
804
804
|
return null;
|
|
805
805
|
}
|
|
806
806
|
command.method = values;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-r/jimp",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.1",
|
|
4
4
|
"description": "Jimp V1 image constructor for E-mc.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"homepage": "https://github.com/anpham6/pi-r2#readme",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@e-mc/core": "^0.13.
|
|
24
|
-
"@e-mc/image": "^0.13.
|
|
25
|
-
"@e-mc/types": "^0.13.
|
|
23
|
+
"@e-mc/core": "^0.13.5",
|
|
24
|
+
"@e-mc/image": "^0.13.5",
|
|
25
|
+
"@e-mc/types": "^0.13.5",
|
|
26
26
|
"@jimp/utils": "^1.6.0",
|
|
27
27
|
"bmp-js": "^0.1.0",
|
|
28
28
|
"gifwrap": "^0.10.1",
|
package/worker/jimp.js
CHANGED
|
@@ -1,29 +1,41 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var node_worker_threads = require('node:worker_threads');
|
|
4
|
-
var jimp
|
|
4
|
+
var jimp = require('jimp');
|
|
5
|
+
var types = require('@e-mc/types');
|
|
5
6
|
|
|
6
7
|
const Image = require("@e-mc/image");
|
|
7
|
-
const
|
|
8
|
+
const JimpApp = require("@pi-r/jimp");
|
|
8
9
|
const PORT = node_worker_threads.workerData[0];
|
|
9
10
|
node_worker_threads.parentPort.on('message', (value) => {
|
|
10
11
|
const { data, commandData, output, options } = value;
|
|
11
|
-
jimp
|
|
12
|
+
jimp.Jimp.read(typeof data === 'string' ? data : Image.asBuffer(data))
|
|
12
13
|
.then(async (img) => {
|
|
13
14
|
const { method, resize, crop, rotate, opacity = -1 } = commandData;
|
|
14
15
|
if (method) {
|
|
15
16
|
for (const [name, args = []] of method) {
|
|
16
|
-
|
|
17
|
+
if (name === 'composite') {
|
|
18
|
+
const [src, x, y, opts] = args;
|
|
19
|
+
if (types.isString(src) && typeof x === 'number' && typeof y === 'number') {
|
|
20
|
+
img.composite(await jimp.Jimp.read(src), x, y, opts);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
throw types.errorMessage(name, "Invalid parameters", JSON.stringify(value));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
JimpApp.applyMethod(img, name, ...args);
|
|
28
|
+
}
|
|
17
29
|
}
|
|
18
30
|
}
|
|
19
31
|
if (resize) {
|
|
20
|
-
|
|
32
|
+
JimpApp.applyResize(img, resize);
|
|
21
33
|
}
|
|
22
34
|
if (crop) {
|
|
23
|
-
|
|
35
|
+
JimpApp.applyCrop(img, crop);
|
|
24
36
|
}
|
|
25
37
|
if (rotate) {
|
|
26
|
-
|
|
38
|
+
JimpApp.applyRotate(img, rotate);
|
|
27
39
|
}
|
|
28
40
|
if (opacity >= 0) {
|
|
29
41
|
img.opacity(opacity);
|