@pi-r/jimp 0.3.4 → 0.3.6

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 CHANGED
@@ -1,7 +1,7 @@
1
- Copyright 2024 An Pham
2
-
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
-
5
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
-
1
+ Copyright 2023 An Pham
2
+
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
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
7
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,7 +1,5 @@
1
- # @pi-r/jimp
2
-
3
- PEP 402 - Forever
4
-
5
- ## LICENSE
6
-
1
+ # @pi-r/jimp
2
+
3
+ ## LICENSE
4
+
7
5
  MIT
package/index.js CHANGED
@@ -30,16 +30,13 @@ const METHOD_ALIAS = {
30
30
  composite: 'cp',
31
31
  mask: 'ma',
32
32
  convolute: 'cl',
33
- convolution: 'cl',
34
33
  flip: 'fl',
35
34
  mirror: 'mi',
36
35
  rotate: 'ro',
37
36
  brightness: 'br',
38
37
  contrast: 'cn',
39
38
  dither565: 'dt',
40
- dither16: 'dt',
41
39
  greyscale: 'gr',
42
- grayscale: 'gr',
43
40
  invert: 'in',
44
41
  normalize: 'no',
45
42
  fade: 'fa',
@@ -52,32 +49,20 @@ const METHOD_ALIAS = {
52
49
  sepia: 'se',
53
50
  pixelate: 'px',
54
51
  displace: 'dp',
55
- color: 'co',
56
- colour: 'co',
57
- backgroundQuiet: 'bq',
58
- circle: 'ci',
59
- colorType: 'ce',
60
- cropQuiet: 'cq',
61
- deflateLevel: 'dl',
62
- deflateStrategy: 'ds',
63
- fishEye: 'fe',
64
- filterType: 'ft',
65
- rgba: 'rg',
66
- shadow: 'sh',
67
- threshold: 'th'
52
+ color: 'co'
68
53
  };
69
54
  function getMethodName(value) {
70
- const name = value.toLowerCase();
71
- if (METHOD_ALIAS[name]) {
72
- return name;
73
- }
74
- if (name.length === 2) {
55
+ if (value.length === 2) {
56
+ value = value.toLowerCase();
75
57
  for (const alias in METHOD_ALIAS) {
76
- if (METHOD_ALIAS[alias] === name) {
58
+ if (METHOD_ALIAS[alias] === value) {
77
59
  return alias;
78
60
  }
79
61
  }
80
62
  }
63
+ else if (METHOD_ALIAS[value] || METHOD_ALIAS[value = value.toLowerCase()]) {
64
+ return value;
65
+ }
81
66
  }
82
67
  function performCommand(host, instance, localUri, command, outputType, finalAs, buffer, parent) {
83
68
  return jimp.read((buffer || localUri))
@@ -85,21 +70,6 @@ function performCommand(host, instance, localUri, command, outputType, finalAs,
85
70
  return transformCommand(localUri, new JimpHandler(img, instance, host), command, outputType, finalAs, parent);
86
71
  });
87
72
  }
88
- function execOptions(settings) {
89
- var _a;
90
- const exec = (_a = settings.jimp) === null || _a === void 0 ? void 0 : _a.exec;
91
- let uid, gid;
92
- if ((0, types_1.isPlainObject)(exec)) {
93
- let { uid: u, gid: g } = exec;
94
- if ((u = parseInt(u)) >= 0) {
95
- uid = u;
96
- }
97
- if ((g = parseInt(g)) >= 0) {
98
- gid = g;
99
- }
100
- }
101
- return { uid, gid };
102
- }
103
73
  async function transformCommand(localFile, handler, command, outputType, outputAs, parent) {
104
74
  if (command) {
105
75
  handler.instance.setCommand(command, outputAs);
@@ -107,11 +77,13 @@ async function transformCommand(localFile, handler, command, outputType, outputA
107
77
  await handler.method();
108
78
  handler.resize();
109
79
  handler.crop();
110
- if (outputType !== jimp.MIME_JPEG) {
111
- handler.opacity();
80
+ if (outputType === jimp.MIME_JPEG) {
81
+ if (!outputAs) {
82
+ handler.quality();
83
+ }
112
84
  }
113
- else if (!outputAs) {
114
- handler.quality();
85
+ else {
86
+ handler.opacity();
115
87
  }
116
88
  switch (handler.rotateCount) {
117
89
  case 0:
@@ -121,9 +93,9 @@ async function transformCommand(localFile, handler, command, outputType, outputA
121
93
  default:
122
94
  return handler.rotate(localFile, (err, result) => {
123
95
  var _a;
124
- if (!err && ((_a = handler.host) === null || _a === void 0 ? void 0 : _a.moduleName) === 'filemanager') {
96
+ if (!err) {
125
97
  try {
126
- handler.host.add(result, parent);
98
+ (_a = handler.host) === null || _a === void 0 ? void 0 : _a.add(result, parent);
127
99
  }
128
100
  catch {
129
101
  }
@@ -283,32 +255,31 @@ class JimpHandler {
283
255
  return;
284
256
  }
285
257
  const data = this.instance.methodData;
286
- if (!data) {
287
- return;
288
- }
289
- const handler = this.handler;
290
- for (const [name, args = []] of data) {
291
- try {
292
- const alias = getMethodName(name);
293
- if (!alias) {
294
- throw (0, types_1.errorValue)("Invalid method name", name);
295
- }
296
- if (alias === 'composite') {
297
- const [src, x, y, opts] = args;
298
- if ((0, types_1.isString)(src) && typeof x === 'number' && typeof y === 'number') {
299
- handler.composite(await jimp.read(src), x, y, opts);
258
+ if (data) {
259
+ const handler = this.handler;
260
+ for (const [name, args = []] of data) {
261
+ try {
262
+ const alias = getMethodName(name);
263
+ if (!alias) {
264
+ throw (0, types_1.errorValue)("Invalid method name", name);
265
+ }
266
+ if (alias === 'composite') {
267
+ const [src, x, y, opts] = args;
268
+ if ((0, types_1.isString)(src) && typeof x === 'number' && typeof y === 'number') {
269
+ handler.composite(await jimp.read(src), x, y, opts);
270
+ }
271
+ else {
272
+ throw (0, types_1.errorValue)("Invalid parameters", alias);
273
+ }
300
274
  }
301
275
  else {
302
- throw (0, types_1.errorValue)("Invalid parameters", alias);
276
+ handler[alias](...args);
303
277
  }
304
278
  }
305
- else {
306
- handler[alias](...args);
279
+ catch (err) {
280
+ this.instance.writeFail(["Unknown", "jimp" + ': ' + name], err, 2048);
307
281
  }
308
282
  }
309
- catch (err) {
310
- this.instance.writeFail(["Unknown", "jimp" + ': ' + name], err, 2048);
311
- }
312
283
  }
313
284
  }
314
285
  resize() {
@@ -316,64 +287,63 @@ class JimpHandler {
316
287
  return;
317
288
  }
318
289
  const data = this.instance.resizeData;
319
- if (!data) {
320
- return;
321
- }
322
- const { width, height, color, algorithm, align, mode } = data;
323
- const handler = this.handler;
324
- if (!isNaN(color)) {
325
- handler.background(color);
326
- }
327
- let resizeMode = jimp.RESIZE_NEAREST_NEIGHBOR, flags = 0;
328
- switch (algorithm) {
329
- case 'bilinear':
330
- resizeMode = jimp.RESIZE_BILINEAR;
331
- break;
332
- case 'bicubic':
333
- resizeMode = jimp.RESIZE_BICUBIC;
334
- break;
335
- case 'hermite':
336
- resizeMode = jimp.RESIZE_HERMITE;
337
- break;
338
- case 'bezier':
339
- resizeMode = jimp.RESIZE_BEZIER;
340
- break;
341
- }
342
- switch (align[0]) {
343
- case 'left':
344
- flags |= jimp.HORIZONTAL_ALIGN_LEFT;
345
- break;
346
- case 'center':
347
- flags |= jimp.HORIZONTAL_ALIGN_CENTER;
348
- break;
349
- case 'right':
350
- flags |= jimp.HORIZONTAL_ALIGN_RIGHT;
351
- break;
352
- }
353
- switch (align[1]) {
354
- case 'top':
355
- flags |= jimp.VERTICAL_ALIGN_TOP;
356
- break;
357
- case 'middle':
358
- flags |= jimp.VERTICAL_ALIGN_MIDDLE;
359
- break;
360
- case 'bottom':
361
- flags |= jimp.VERTICAL_ALIGN_BOTTOM;
362
- break;
363
- }
364
- switch (mode) {
365
- case 'contain':
366
- handler.contain(width, height, flags);
367
- break;
368
- case 'cover':
369
- handler.cover(width, height, flags);
370
- break;
371
- case 'scale':
372
- handler.scaleToFit(width, height);
373
- break;
374
- default:
375
- handler.resize(width === Infinity ? jimp.AUTO : width, height === Infinity ? jimp.AUTO : height, resizeMode);
376
- break;
290
+ if (data) {
291
+ const { width, height, color, algorithm, align, mode } = data;
292
+ const handler = this.handler;
293
+ if (!isNaN(color)) {
294
+ handler.background(color);
295
+ }
296
+ let resizeMode = jimp.RESIZE_NEAREST_NEIGHBOR, flags = 0;
297
+ switch (algorithm) {
298
+ case 'bilinear':
299
+ resizeMode = jimp.RESIZE_BILINEAR;
300
+ break;
301
+ case 'bicubic':
302
+ resizeMode = jimp.RESIZE_BICUBIC;
303
+ break;
304
+ case 'hermite':
305
+ resizeMode = jimp.RESIZE_HERMITE;
306
+ break;
307
+ case 'bezier':
308
+ resizeMode = jimp.RESIZE_BEZIER;
309
+ break;
310
+ }
311
+ switch (align[0]) {
312
+ case 'left':
313
+ flags |= jimp.HORIZONTAL_ALIGN_LEFT;
314
+ break;
315
+ case 'center':
316
+ flags |= jimp.HORIZONTAL_ALIGN_CENTER;
317
+ break;
318
+ case 'right':
319
+ flags |= jimp.HORIZONTAL_ALIGN_RIGHT;
320
+ break;
321
+ }
322
+ switch (align[1]) {
323
+ case 'top':
324
+ flags |= jimp.VERTICAL_ALIGN_TOP;
325
+ break;
326
+ case 'middle':
327
+ flags |= jimp.VERTICAL_ALIGN_MIDDLE;
328
+ break;
329
+ case 'bottom':
330
+ flags |= jimp.VERTICAL_ALIGN_BOTTOM;
331
+ break;
332
+ }
333
+ switch (mode) {
334
+ case 'contain':
335
+ handler.contain(width, height, flags);
336
+ break;
337
+ case 'cover':
338
+ handler.cover(width, height, flags);
339
+ break;
340
+ case 'scale':
341
+ handler.scaleToFit(width, height);
342
+ break;
343
+ default:
344
+ handler.resize(width === Infinity ? jimp.AUTO : width, height === Infinity ? jimp.AUTO : height, resizeMode);
345
+ break;
346
+ }
377
347
  }
378
348
  }
379
349
  background(value) {
@@ -383,13 +353,13 @@ class JimpHandler {
383
353
  this.handler.background(value);
384
354
  }
385
355
  finalize(output, callback) {
356
+ var _a;
386
357
  if (this.aborted) {
387
358
  return;
388
359
  }
389
360
  const instance = this.instance;
390
361
  if (instance.outputAs === 'webp' && path.extname(output).toLowerCase() !== '.webp') {
391
- const settings = instance.settings;
392
- const webp = settings.webp || (settings.webp = {});
362
+ const webp = (_a = instance.settings).webp || (_a.webp = {});
393
363
  const data = instance.qualityData;
394
364
  const replace = instance.getCommand().indexOf('@') !== -1;
395
365
  const filename = (0, util_1.renameExt)(output, 'webp', replace);
@@ -436,7 +406,7 @@ class JimpHandler {
436
406
  }
437
407
  args.push('-o', (0, util_1.normalizePath)(filename));
438
408
  try {
439
- child_process.execFile((0, util_1.getWebP_bin)('cwebp', webp.path), args, { shell: true, signal: this.instance.signal, ...execOptions(settings) }, err => {
409
+ child_process.execFile((0, util_1.getWebP_bin)('cwebp', webp.path), args, { shell: true, signal: this.instance.signal }, err => {
440
410
  if (err) {
441
411
  this.instance.writeFail(["Unable to convert file", path.basename(filename)], err, 2048);
442
412
  }
@@ -575,67 +545,67 @@ class Jimp extends Image {
575
545
  static async transform(file, command, options = {}) {
576
546
  const [outputType, saveAs, finalAs] = (0, util_1.parseFormat)(command = command.trim(), options.mimeType);
577
547
  const empty = () => options.tempFile ? '' : null;
578
- if (!outputType) {
579
- return empty();
580
- }
581
- const instance = new Jimp(options.module);
582
- let buffer = null;
583
- if (Buffer.isBuffer(file)) {
584
- const tempDir = TEMP_DIR || instance.getTempDir();
585
- if (!this.createDir(tempDir)) {
586
- return empty();
587
- }
588
- try {
589
- const { ext } = await this.resolveMime(file) || { ext: 'unknown' };
590
- buffer = file;
591
- fs.writeFileSync(file = path.join(tempDir, (0, types_1.generateUUID)() + '.' + ext), buffer);
592
- }
593
- catch {
594
- return empty();
548
+ if (outputType) {
549
+ const instance = new Jimp(options.module);
550
+ let buffer = null;
551
+ if (Buffer.isBuffer(file)) {
552
+ const tempDir = TEMP_DIR || instance.getTempDir();
553
+ if (!this.createDir(tempDir)) {
554
+ return empty();
555
+ }
556
+ try {
557
+ const { ext } = await this.resolveMime(file) || { ext: 'unknown' };
558
+ buffer = file;
559
+ fs.writeFileSync(file = path.join(tempDir, (0, types_1.generateUUID)() + '.' + ext), buffer);
560
+ }
561
+ catch {
562
+ return empty();
563
+ }
564
+ options.cache = false;
565
+ }
566
+ const filename = path.basename(file);
567
+ const broadcastId = options.broadcastId;
568
+ if (broadcastId) {
569
+ if ((0, types_1.isPlainObject)(broadcastId)) {
570
+ instance.broadcastId = broadcastId.value;
571
+ if (broadcastId.stripAnsi === false) {
572
+ instance.supports('stripAnsi', false);
573
+ }
574
+ }
575
+ else {
576
+ instance.broadcastId = broadcastId;
577
+ }
595
578
  }
596
- options.cache = false;
597
- }
598
- const filename = path.basename(file);
599
- const broadcastId = options.broadcastId;
600
- if (broadcastId) {
601
- if ((0, types_1.isPlainObject)(broadcastId)) {
602
- instance.broadcastId = broadcastId.value;
603
- if (broadcastId.stripAnsi === false) {
604
- instance.supports('stripAnsi', false);
579
+ const writeMessage = (failed, cTimeMs) => {
580
+ if (cTimeMs || options.startTime) {
581
+ formatMessage.call(instance, filename + (0, util_1.showOutputType)(options.mimeType, outputType, finalAs), options.startTime, failed, cTimeMs);
582
+ }
583
+ };
584
+ let tempKey, tempFile;
585
+ if (options.cache) {
586
+ let ctimeMs;
587
+ [buffer, tempFile, ctimeMs] = getImageCache.call(instance, tempKey = file + command + (options.mimeType || ''));
588
+ if (buffer) {
589
+ writeMessage(false, ctimeMs);
590
+ return Promise.resolve(buffer);
605
591
  }
606
592
  }
607
- else {
608
- instance.broadcastId = broadcastId;
609
- }
610
- }
611
- const writeMessage = (failed, cTimeMs) => {
612
- if (cTimeMs || options.startTime) {
613
- formatMessage.call(instance, filename + (0, util_1.showOutputType)(options.mimeType, outputType, finalAs), options.startTime, failed, cTimeMs);
614
- }
615
- };
616
- let tempKey, tempFile;
617
- if (options.cache) {
618
- let ctimeMs;
619
- [buffer, tempFile, ctimeMs] = getImageCache.call(instance, tempKey = file + command + (options.mimeType || ''));
620
- if (buffer) {
621
- writeMessage(false, ctimeMs);
622
- return Promise.resolve(buffer);
623
- }
624
- }
625
- instance.formatMessage(Image.LOG_TYPE.IMAGE, "jimp", ["Transforming image...", filename], command);
626
- Image.initCpuUsage(instance);
627
- return performCommand(null, instance, file, command, outputType, finalAs)
628
- .then(async (handler) => {
629
- const result = await handler.getBuffer(options.tempFile, saveAs);
630
- instance.flushLog();
631
- writeMessage(!result || instance.errors.length > 0);
632
- if (result && tempKey && tempFile) {
633
- setImageCache.call(instance, tempKey, tempFile, result, file);
634
- }
635
- return result;
636
- })
637
- .catch(() => empty())
638
- .finally(() => buffer && !options.cache && removeFile(file));
593
+ instance.formatMessage(Image.LOG_TYPE.IMAGE, "jimp", ["Transforming image...", filename], command);
594
+ Image.initCpuUsage(instance);
595
+ return performCommand(null, instance, file, command, outputType, finalAs)
596
+ .then(async (handler) => {
597
+ const result = await handler.getBuffer(options.tempFile, saveAs);
598
+ instance.flushLog();
599
+ writeMessage(!result || instance.errors.length > 0);
600
+ if (result && tempKey && tempFile) {
601
+ setImageCache.call(instance, tempKey, tempFile, result, file);
602
+ }
603
+ return result;
604
+ })
605
+ .catch(() => empty())
606
+ .finally(() => buffer && !options.cache && removeFile(file));
607
+ }
608
+ return empty();
639
609
  }
640
610
  parseRotate(value) {
641
611
  var _a;
@@ -654,6 +624,7 @@ class Jimp extends Image {
654
624
  }
655
625
  return new Promise(async (resolve, reject) => {
656
626
  var _a;
627
+ var _b;
657
628
  const { host, file } = data;
658
629
  const localUri = host.getLocalUri(data);
659
630
  const mimeType = host.getMimeType(data);
@@ -683,9 +654,8 @@ class Jimp extends Image {
683
654
  const startTime = process.hrtime();
684
655
  const success = (result, ctimeMs) => {
685
656
  const filename = path.basename(result);
686
- const document = file.document;
687
- if (document) {
688
- host.writeImage(document, data.getObject({ command, output: result }));
657
+ if (file.document) {
658
+ host.writeImage(file.document, data.getObject({ command, output: result }));
689
659
  }
690
660
  if (host.getLocalUri(data) !== result) {
691
661
  if (command.indexOf('%') !== -1) {
@@ -796,12 +766,11 @@ class Jimp extends Image {
796
766
  const args = [(0, util_1.normalizePath)(target)];
797
767
  const quality = cmd.quality;
798
768
  if (quality) {
799
- const { value, method } = quality;
800
- if (!isNaN(value)) {
801
- args.push('-q', value.toString());
769
+ if (!isNaN(quality.value)) {
770
+ args.push('-q', quality.value.toString());
802
771
  }
803
- if (!isNaN(method)) {
804
- args.push('-m', method.toString());
772
+ if (!isNaN(quality.method)) {
773
+ args.push('-m', quality.method.toString());
805
774
  }
806
775
  }
807
776
  if (Array.isArray(gif2webp)) {
@@ -830,7 +799,7 @@ class Jimp extends Image {
830
799
  }
831
800
  args.push('-o', (0, util_1.normalizePath)(webp));
832
801
  try {
833
- child_process.execFile((0, util_1.getWebP_bin)('gif2webp', webp_path), args, { shell: true, signal: this.signal, ...execOptions(this.settings) }, (err, stdout) => {
802
+ child_process.execFile((0, util_1.getWebP_bin)('gif2webp', webp_path), args, { shell: true, signal: this.signal }, (err, stdout) => {
834
803
  if (!err) {
835
804
  this.addLog(types_1.STATUS_TYPE.INFO, stdout);
836
805
  finalize(webp);
@@ -975,11 +944,10 @@ class Jimp extends Image {
975
944
  }
976
945
  return false;
977
946
  };
978
- const settings = this.settings;
979
- const { path: webp_path } = settings.webp || (settings.webp = {});
947
+ const { path: webp_path } = (_b = this.settings).webp || (_b.webp = {});
980
948
  const bmpFile = getTempPath.call(this, 'bmp');
981
949
  try {
982
- child_process.execFile((0, util_1.getWebP_bin)('dwebp', webp_path), [(0, util_1.normalizePath)(localUri), '-bmp', '-o', (0, util_1.normalizePath)(bmpFile)], { shell: true, signal: this.signal, ...execOptions(settings) }, err => {
950
+ child_process.execFile((0, util_1.getWebP_bin)('dwebp', webp_path), [(0, util_1.normalizePath)(localUri), '-bmp', '-o', (0, util_1.normalizePath)(bmpFile)], { shell: true, signal: this.signal }, err => {
983
951
  if (!err) {
984
952
  transformBuffer(bmpFile);
985
953
  }
package/package.json CHANGED
@@ -1,29 +1,29 @@
1
- {
2
- "name": "@pi-r/jimp",
3
- "version": "0.3.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.6.3",
24
- "@e-mc/types": "^0.6.3",
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.3.6",
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.6.16",
24
+ "@e-mc/types": "^0.6.16",
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;
package/util.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- declare namespace util {
2
- function parseFormat(command: string, mimeType?: string, gif?: boolean): [string, string, string];
3
- function renameExt(output: string, ext: string, replace?: boolean): string;
4
- function normalizePath(value: string): string;
5
- function getWebP_bin(name: string, pathname: string | undefined): string;
6
- function showInputType(value: string | undefined, outputType: string, finalAs: string): string;
7
- function showOutputType(value: string | undefined, outputType: string, finalAs: string): string;
8
- }
9
-
1
+ declare namespace util {
2
+ function parseFormat(command: string, mimeType?: string, gif?: boolean): [string, string, string];
3
+ function renameExt(output: string, ext: string, replace?: boolean): string;
4
+ function normalizePath(value: string): string;
5
+ function getWebP_bin(name: string, pathname: string | undefined): string;
6
+ function showInputType(value: string | undefined, outputType: string, finalAs: string): string;
7
+ function showOutputType(value: string | undefined, outputType: string, finalAs: string): string;
8
+ }
9
+
10
10
  export = util;