@pi-r/jimp 0.7.2 → 0.7.4
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/README.md +6 -6
- package/index.js +6 -5
- package/package.json +29 -29
- package/types/index.d.ts +18 -18
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
### @pi-r/jimp
|
|
2
|
-
|
|
3
|
-
https://e-mc.readthedocs.io/en/latest/image
|
|
4
|
-
|
|
5
|
-
### LICENSE
|
|
6
|
-
|
|
1
|
+
### @pi-r/jimp
|
|
2
|
+
|
|
3
|
+
https://e-mc.readthedocs.io/en/latest/image
|
|
4
|
+
|
|
5
|
+
### LICENSE
|
|
6
|
+
|
|
7
7
|
MIT
|
package/index.js
CHANGED
|
@@ -232,12 +232,10 @@ function getTempPath(ext) {
|
|
|
232
232
|
}
|
|
233
233
|
const removeFile = (pathname) => fs.unlink(pathname, () => { });
|
|
234
234
|
class JimpHandler {
|
|
235
|
-
handler;
|
|
236
|
-
instance;
|
|
237
|
-
_host = null;
|
|
238
235
|
constructor(handler, instance, host) {
|
|
239
236
|
this.handler = handler;
|
|
240
237
|
this.instance = instance;
|
|
238
|
+
this._host = null;
|
|
241
239
|
if (host) {
|
|
242
240
|
this._host = host;
|
|
243
241
|
}
|
|
@@ -562,6 +560,11 @@ class JimpHandler {
|
|
|
562
560
|
}
|
|
563
561
|
}
|
|
564
562
|
class Jimp extends Image {
|
|
563
|
+
constructor() {
|
|
564
|
+
super(...arguments);
|
|
565
|
+
this._moduleName = "jimp";
|
|
566
|
+
this._threadable = true;
|
|
567
|
+
}
|
|
565
568
|
static async transform(file, command, options = {}) {
|
|
566
569
|
const [outputType, saveAs, finalAs] = (0, util_1.parseFormat)(command = command.trim(), options.mimeType);
|
|
567
570
|
const empty = () => options.tempFile ? '' : null;
|
|
@@ -627,8 +630,6 @@ class Jimp extends Image {
|
|
|
627
630
|
.catch(() => empty())
|
|
628
631
|
.finally(() => buffer && !options.cache && removeFile(file));
|
|
629
632
|
}
|
|
630
|
-
_moduleName = "jimp";
|
|
631
|
-
_threadable = true;
|
|
632
633
|
parseRotate(value) {
|
|
633
634
|
const data = super.parseRotate(value);
|
|
634
635
|
if (data && this.settings.jimp?.rotate_clockwise) {
|
package/package.json
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@pi-r/jimp",
|
|
3
|
-
"version": "0.7.
|
|
4
|
-
"description": "Jimp image constructor for E-mc.",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"publishConfig": {
|
|
7
|
-
"access": "public"
|
|
8
|
-
},
|
|
9
|
-
"repository": {
|
|
10
|
-
"type": "git",
|
|
11
|
-
"url": "git+https://github.com/anpham6/pi-r.git",
|
|
12
|
-
"directory": "src/module/jimp"
|
|
13
|
-
},
|
|
14
|
-
"keywords": [
|
|
15
|
-
"squared",
|
|
16
|
-
"e-mc",
|
|
17
|
-
"squared-functions"
|
|
18
|
-
],
|
|
19
|
-
"author": "An Pham <anpham6@gmail.com>",
|
|
20
|
-
"license": "MIT",
|
|
21
|
-
"homepage": "https://github.com/anpham6/pi-r#readme",
|
|
22
|
-
"dependencies": {
|
|
23
|
-
"@e-mc/image": "^0.9.
|
|
24
|
-
"@e-mc/types": "^0.9.
|
|
25
|
-
"bmp-js": "^0.1.0",
|
|
26
|
-
"gifwrap": "^0.10.1",
|
|
27
|
-
"jimp": "^0.22.12"
|
|
28
|
-
}
|
|
29
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@pi-r/jimp",
|
|
3
|
+
"version": "0.7.4",
|
|
4
|
+
"description": "Jimp image constructor for E-mc.",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/anpham6/pi-r.git",
|
|
12
|
+
"directory": "src/module/jimp"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"squared",
|
|
16
|
+
"e-mc",
|
|
17
|
+
"squared-functions"
|
|
18
|
+
],
|
|
19
|
+
"author": "An Pham <anpham6@gmail.com>",
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"homepage": "https://github.com/anpham6/pi-r#readme",
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@e-mc/image": "^0.9.12",
|
|
24
|
+
"@e-mc/types": "^0.9.12",
|
|
25
|
+
"bmp-js": "^0.1.0",
|
|
26
|
+
"gifwrap": "^0.10.1",
|
|
27
|
+
"jimp": "^0.22.12"
|
|
28
|
+
}
|
|
29
|
+
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import type { IHost, IImage, ImageConstructor } from '@e-mc/types/lib';
|
|
2
|
-
import type { ImageModule } from '@e-mc/types/lib/settings';
|
|
3
|
-
|
|
4
|
-
import type { ImageHandler } from '@e-mc/image/types';
|
|
5
|
-
|
|
6
|
-
import type * as jimp from 'jimp';
|
|
7
|
-
|
|
8
|
-
export interface IJimpHandler<T extends IHost = IHost, U extends ImageModule = ImageModule> extends ImageHandler<jimp, T, IImage<T, U>> {
|
|
9
|
-
method(): Promise<void>;
|
|
10
|
-
rotate(localFile?: string, callback?: ResultCallback<string>): Promise<this>;
|
|
11
|
-
background(value: number | [number, number, number, number]): void;
|
|
12
|
-
writeAsync(output: string, callback?: ResultCallback): Promise<void>;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export interface JimpImageConstructor extends ImageConstructor {
|
|
16
|
-
new(handler: jimp, instance: IImage, host?: Null<IHost>): IJimpHandler;
|
|
17
|
-
}
|
|
18
|
-
|
|
1
|
+
import type { IHost, IImage, ImageConstructor } from '@e-mc/types/lib';
|
|
2
|
+
import type { ImageModule } from '@e-mc/types/lib/settings';
|
|
3
|
+
|
|
4
|
+
import type { ImageHandler } from '@e-mc/image/types';
|
|
5
|
+
|
|
6
|
+
import type * as jimp from 'jimp';
|
|
7
|
+
|
|
8
|
+
export interface IJimpHandler<T extends IHost = IHost, U extends ImageModule = ImageModule> extends ImageHandler<jimp, T, IImage<T, U>> {
|
|
9
|
+
method(): Promise<void>;
|
|
10
|
+
rotate(localFile?: string, callback?: ResultCallback<string>): Promise<this>;
|
|
11
|
+
background(value: number | [number, number, number, number]): void;
|
|
12
|
+
writeAsync(output: string, callback?: ResultCallback): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface JimpImageConstructor extends ImageConstructor {
|
|
16
|
+
new(handler: jimp, instance: IImage, host?: Null<IHost>): IJimpHandler;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
19
|
export type ResultCallback<T = unknown, U = void, V = unknown> = (err: V, result: T) => U;
|