1 | import * as Jimp from "jimp";
|
2 |
|
3 | const jimpInst: Jimp = new Jimp("test");
|
4 |
|
5 |
|
6 | jimpInst.read("Test");
|
7 | jimpInst.displace(jimpInst, 2);
|
8 | jimpInst.resize(40, 40);
|
9 |
|
10 | jimpInst.PNG_FILTER_NONE;
|
11 |
|
12 |
|
13 | jimpInst.test;
|
14 |
|
15 |
|
16 | jimpInst.func();
|
17 |
|
18 |
|
19 | Jimp.read("Test");
|
20 | Jimp.displace(Jimp, 2);
|
21 | Jimp.shadow((err, val, coords) => {});
|
22 | Jimp.resize(40, 40);
|
23 |
|
24 | Jimp.PNG_FILTER_NONE;
|
25 |
|
26 |
|
27 | Jimp.test;
|
28 |
|
29 |
|
30 | Jimp.func();
|
31 |
|
32 | test("can clone properly", async () => {
|
33 | const baseImage = await Jimp.read("filename");
|
34 | const cloneBaseImage = baseImage.clone();
|
35 |
|
36 |
|
37 | cloneBaseImage.PNG_FILTER_AUTO;
|
38 |
|
39 | test("can handle `this` returns on the core type properly", () => {
|
40 |
|
41 | cloneBaseImage.diff(jimpInst, jimpInst).image.PNG_FILTER_AUTO;
|
42 | });
|
43 |
|
44 | test("can handle `this` returns properly", () => {
|
45 | cloneBaseImage
|
46 | .resize(1, 1)
|
47 | .crop(0, 0, 0, 0)
|
48 | .mask(cloneBaseImage, 2, 2)
|
49 | .print("a" as any, 2, 2, "a" as any)
|
50 | .resize(1, 1)
|
51 | .quality(1)
|
52 | .deflateLevel(2).PNG_FILTER_AUTO;
|
53 | });
|
54 |
|
55 | test("can handle imageCallbacks `this` properly", () => {
|
56 | cloneBaseImage.rgba(false, (_, jimpCBIn) => {
|
57 | jimpCBIn.read("Test");
|
58 | jimpCBIn.displace(jimpInst, 2);
|
59 | jimpCBIn.resize(40, 40);
|
60 |
|
61 | jimpCBIn.PNG_FILTER_NONE;
|
62 |
|
63 |
|
64 | jimpCBIn.test;
|
65 |
|
66 |
|
67 | jimpCBIn.func();
|
68 | });
|
69 | });
|
70 | });
|
71 |
|
72 | test("Can handle callback with constructor", () => {
|
73 | const myBmpBuffer: Buffer = {} as any;
|
74 |
|
75 | Jimp.read(myBmpBuffer, (err, cbJimpInst) => {
|
76 | cbJimpInst.read("Test");
|
77 | cbJimpInst.displace(jimpInst, 2);
|
78 | cbJimpInst.resize(40, 40);
|
79 |
|
80 | cbJimpInst.PNG_FILTER_NONE;
|
81 |
|
82 |
|
83 | cbJimpInst.test;
|
84 |
|
85 |
|
86 | cbJimpInst.func();
|
87 | });
|
88 | });
|
89 |
|
90 | test("Can handle appendConstructorOption", () => {
|
91 | Jimp.appendConstructorOption(
|
92 | "Name of Option",
|
93 | (args) => args.hasSomeCustomThing,
|
94 | function (resolve, reject, args) {
|
95 |
|
96 | this.bitmap = 3;
|
97 | Jimp.resize(2, 2);
|
98 | resolve();
|
99 | }
|
100 | );
|
101 | });
|