@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.
Files changed (4) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +1 -1
  3. package/index.js +76 -78
  4. package/package.json +3 -3
package/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2023 Studio Trigger
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
@@ -1,6 +1,6 @@
1
1
  # @pi-r/jimp
2
2
 
3
- PEP 402 - Forever Aina
3
+ PEP 402 - Forever Vivy
4
4
 
5
5
  ## LICENSE
6
6
 
package/index.js CHANGED
@@ -282,32 +282,31 @@ class JimpHandler {
282
282
  return;
283
283
  }
284
284
  const data = this.instance.methodData;
285
- if (!data) {
286
- return;
287
- }
288
- const handler = this.handler;
289
- for (const [name, args = []] of data) {
290
- try {
291
- const alias = getMethodName(name);
292
- if (!alias) {
293
- throw (0, types_1.errorValue)("Invalid method name", name);
294
- }
295
- if (alias === 'composite') {
296
- const [src, x, y, opts] = args;
297
- if ((0, types_1.isString)(src) && typeof x === 'number' && typeof y === 'number') {
298
- handler.composite(await jimp.read(src), x, y, opts);
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
- throw (0, types_1.errorValue)("Invalid parameters", alias);
303
+ handler[alias](...args);
302
304
  }
303
305
  }
304
- else {
305
- handler[alias](...args);
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 (!data) {
319
- return;
320
- }
321
- const { width, height, color, algorithm, align, mode } = data;
322
- const handler = this.handler;
323
- if (!isNaN(color)) {
324
- handler.background(color);
325
- }
326
- let resizeMode = jimp.RESIZE_NEAREST_NEIGHBOR, flags = 0;
327
- switch (algorithm) {
328
- case 'bilinear':
329
- resizeMode = jimp.RESIZE_BILINEAR;
330
- break;
331
- case 'bicubic':
332
- resizeMode = jimp.RESIZE_BICUBIC;
333
- break;
334
- case 'hermite':
335
- resizeMode = jimp.RESIZE_HERMITE;
336
- break;
337
- case 'bezier':
338
- resizeMode = jimp.RESIZE_BEZIER;
339
- break;
340
- }
341
- switch (align[0]) {
342
- case 'left':
343
- flags |= jimp.HORIZONTAL_ALIGN_LEFT;
344
- break;
345
- case 'center':
346
- flags |= jimp.HORIZONTAL_ALIGN_CENTER;
347
- break;
348
- case 'right':
349
- flags |= jimp.HORIZONTAL_ALIGN_RIGHT;
350
- break;
351
- }
352
- switch (align[1]) {
353
- case 'top':
354
- flags |= jimp.VERTICAL_ALIGN_TOP;
355
- break;
356
- case 'middle':
357
- flags |= jimp.VERTICAL_ALIGN_MIDDLE;
358
- break;
359
- case 'bottom':
360
- flags |= jimp.VERTICAL_ALIGN_BOTTOM;
361
- break;
362
- }
363
- switch (mode) {
364
- case 'contain':
365
- handler.contain(width, height, flags);
366
- break;
367
- case 'cover':
368
- handler.cover(width, height, flags);
369
- break;
370
- case 'scale':
371
- handler.scaleToFit(width, height);
372
- break;
373
- default:
374
- handler.resize(width === Infinity ? jimp.AUTO : width, height === Infinity ? jimp.AUTO : height, resizeMode);
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.2",
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.6.1",
24
- "@e-mc/types": "^0.6.1",
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"