@pi-r/jimp 0.11.3 → 0.12.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 CHANGED
@@ -1,18 +1,17 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
- var core = require('@e-mc/core');
4
- var types = require('@e-mc/types');
5
-
6
- const path = require("node:path");
7
- const fs = require("node:fs");
8
- const crypto = require("node:crypto");
9
- const child_process = require("node:child_process");
10
- const jimp = require("jimp");
11
- const jimp_utils = require("@jimp/utils");
12
- const gifwrap = require("gifwrap");
13
- const bmp = require("bmp-js");
3
+ const path = require('node:path');
4
+ const fs = require('node:fs');
5
+ const child_process = require('node:child_process');
6
+ const gifwrap = require('gifwrap');
7
+ const { randomUUID } = require('node:crypto');
8
+ const jimp = require('jimp');
9
+ const { encode } = require('bmp-js');
10
+ const { rgbaToInt } = require('@jimp/utils');
11
+ const { WorkerChannel, WorkerGroup } = require('@e-mc/core');
14
12
  const Image = require('@e-mc/image');
15
- const util = require("@pi-r/jimp/util");
13
+ const { ERR_CODE, createAbortError, errorMessage, errorValue, getTempDir, isErrorCode, isPlainObject, isString, parseExpires, sanitizeCmd } = require('@e-mc/types');
14
+ const util = require('@pi-r/jimp/util');
16
15
  const kJimp = Symbol.for('jimp:constructor');
17
16
  let WEBPMUX = null, WEBPMUX_INIT = false;
18
17
  try {
@@ -23,7 +22,7 @@ catch {
23
22
  }
24
23
  const CACHE_TRANSFORM = {};
25
24
  const FONT_DATA = {};
26
- const WORKER_JIMP = core.WorkerChannel.create(path.join(__dirname, 'worker', 'jimp.js'), 'PIR_JIMP');
25
+ const WORKER_JIMP = WorkerChannel.create(path.join(__dirname, 'worker', 'jimp.js'), 'PIR_JIMP');
27
26
  let CACHE_INIT = false;
28
27
  let TEMP_DIR = '';
29
28
  const METHOD_ALIAS = {
@@ -87,7 +86,7 @@ const METHOD_ALIAS = {
87
86
  });
88
87
  }
89
88
  function getMethodName(value) {
90
- if (types.isString(value)) {
89
+ if (isString(value)) {
91
90
  if (value.length === 2) {
92
91
  value = value.toLowerCase();
93
92
  for (const alias in METHOD_ALIAS) {
@@ -110,7 +109,7 @@ async function performCommand(instance, buffer, command, outputType, outputAs, o
110
109
  function execOptions(settings) {
111
110
  const exec = settings.jimp?.exec;
112
111
  let uid, gid;
113
- if (types.isPlainObject(exec)) {
112
+ if (isPlainObject(exec)) {
114
113
  let { uid: u, gid: g } = exec;
115
114
  if ((u = parseInt(u)) >= 0) {
116
115
  uid = u;
@@ -197,13 +196,13 @@ function getImageCache(instance, tempKey) {
197
196
  delete stored[tempKey];
198
197
  }
199
198
  setTempDir(instance);
200
- return [null, path.join(TEMP_DIR, crypto.randomUUID())];
199
+ return [null, path.join(TEMP_DIR, randomUUID())];
201
200
  }
202
201
  function getCacheData(instance) {
203
202
  if (!CACHE_INIT) {
204
203
  setTempDir(instance);
205
204
  const settings = instance.settings.jimp ||= {};
206
- const expires = types.parseExpires(settings.cache_expires || 0);
205
+ const expires = parseExpires(settings.cache_expires || 0);
207
206
  if (settings.worker) {
208
207
  let { min = -1, max = -1, expires: idleTimeout = 0 } = settings.worker;
209
208
  if ((min = Math.trunc(+min)) >= 0) {
@@ -212,7 +211,7 @@ function getCacheData(instance) {
212
211
  if ((max = Math.trunc(+max)) >= 0) {
213
212
  WORKER_JIMP.max = max;
214
213
  }
215
- if ((idleTimeout = types.parseExpires(idleTimeout)) > 0) {
214
+ if ((idleTimeout = parseExpires(idleTimeout)) > 0) {
216
215
  WORKER_JIMP.idleTimeout = idleTimeout;
217
216
  }
218
217
  }
@@ -231,7 +230,7 @@ function getCacheData(instance) {
231
230
  const pathname = path.join(TEMP_DIR, item.name);
232
231
  try {
233
232
  const data = JSON.parse(fs.readFileSync(pathname, 'utf8'));
234
- if (types.isPlainObject(data) && fs.existsSync(data.tempFile)) {
233
+ if (isPlainObject(data) && fs.existsSync(data.tempFile)) {
235
234
  if (data.ctimeMs + expires > current) {
236
235
  CACHE_TRANSFORM[data.tempKey] = data;
237
236
  return;
@@ -266,7 +265,7 @@ function formatMessage(instance, value, startTime, failed, worker = false, cTime
266
265
  }
267
266
  function getTempPath(instance, ext) {
268
267
  setTempDir(instance);
269
- return path.join(TEMP_DIR, crypto.randomUUID() + '.' + ext);
268
+ return path.join(TEMP_DIR, randomUUID() + '.' + ext);
270
269
  }
271
270
  function rotateAnim(cmd) {
272
271
  const rotate = cmd.rotate;
@@ -275,16 +274,16 @@ function rotateAnim(cmd) {
275
274
  }
276
275
  }
277
276
  function setBackground(instance, args) {
278
- instance.background = jimp_utils.rgbaToInt(...args);
277
+ instance.background = rgbaToInt(...args);
279
278
  }
280
279
  function removeFile(pathname) {
281
280
  fs.unlink(pathname, () => { });
282
281
  }
283
282
  function errorParameters(alias, value) {
284
- throw types.errorMessage(alias, "Invalid parameters", JSON.stringify(value));
283
+ throw errorMessage(alias, "Invalid parameters", JSON.stringify(value));
285
284
  }
286
285
  function setTempDir(instance) {
287
- TEMP_DIR ||= instance.getTempDir({ moduleDir: true, createDir: true }) || types.getTempDir(true, "jimp");
286
+ TEMP_DIR ||= instance.getTempDir({ moduleDir: true, createDir: true }) || getTempDir(true, "jimp");
288
287
  }
289
288
  const hasTransform = (cmd) => !!(cmd.rotate || cmd.resize || cmd.crop || cmd.method || typeof cmd.opacity === 'number' && cmd.opacity >= 0 && cmd.opacity < 1);
290
289
  const isUnsupported = (value) => value === Image.MIME_GIF || value === Image.MIME_WEBP;
@@ -309,7 +308,7 @@ class JimpHandler {
309
308
  return;
310
309
  }
311
310
  Jimp.applyBackground(this.handler, data);
312
- const leading = output.substring(0, output.lastIndexOf('.') + 1);
311
+ const leading = output.slice(0, output.lastIndexOf('.') + 1);
313
312
  const ext = path.extname(output);
314
313
  const tasks = [];
315
314
  for (let i = 0; i < data.values.length; i++) {
@@ -342,7 +341,7 @@ class JimpHandler {
342
341
  const alias = getMethodName(name);
343
342
  if (alias === 'composite') {
344
343
  const [src, x, y, opts] = args;
345
- if (types.isString(src) && typeof x === 'number' && typeof y === 'number') {
344
+ if (isString(src) && typeof x === 'number' && typeof y === 'number') {
346
345
  this.handler.composite(await jimp.Jimp.read(src), x, y, opts);
347
346
  }
348
347
  else {
@@ -356,7 +355,7 @@ class JimpHandler {
356
355
  }
357
356
  }
358
357
  else {
359
- throw types.errorValue("Invalid method name", name);
358
+ throw errorValue("Invalid method name", name);
360
359
  }
361
360
  }
362
361
  catch (err) {
@@ -375,7 +374,7 @@ class JimpHandler {
375
374
  }
376
375
  }
377
376
  background(value) {
378
- this.handler.background = Array.isArray(value) ? jimp_utils.rgbaToInt(...value) : value;
377
+ this.handler.background = Array.isArray(value) ? rgbaToInt(...value) : value;
379
378
  }
380
379
  async finalize(output, callback, replace) {
381
380
  if (this.aborted) {
@@ -430,7 +429,7 @@ class JimpHandler {
430
429
  }
431
430
  args.push('-o', util.normalizePath(outFile));
432
431
  try {
433
- child_process.execFile(types.sanitizeCmd(await util.importBinary('cwebp', webp.path), args), { shell: true, signal: this.instance.signal, ...execOptions(settings) }, err => {
432
+ child_process.execFile(sanitizeCmd(await util.importBinary('cwebp', webp.path), args), { shell: true, signal: this.instance.signal, ...execOptions(settings) }, err => {
434
433
  if (err) {
435
434
  this.instance.writeFail(["Unable to convert file", path.basename(outFile)], err, 2048);
436
435
  }
@@ -518,7 +517,7 @@ class JimpHandler {
518
517
  async write(output, callback) {
519
518
  if (this.aborted) {
520
519
  if (callback) {
521
- callback(types.createAbortError(), '');
520
+ callback(createAbortError(), '');
522
521
  }
523
522
  return;
524
523
  }
@@ -555,7 +554,7 @@ class Jimp extends Image {
555
554
  setTempDir(instance);
556
555
  const { mime, ext } = await this.resolveMime(file) || { ext: 'unknown' };
557
556
  buffer = file;
558
- fs.writeFileSync(file = path.join(TEMP_DIR, crypto.randomUUID() + '.' + ext), buffer);
557
+ fs.writeFileSync(file = path.join(TEMP_DIR, randomUUID() + '.' + ext), buffer);
559
558
  if (mime) {
560
559
  options.mimeType = mime;
561
560
  }
@@ -575,7 +574,7 @@ class Jimp extends Image {
575
574
  const filename = path.basename(file);
576
575
  const broadcastId = options.broadcastId;
577
576
  if (broadcastId) {
578
- if (types.isPlainObject(broadcastId)) {
577
+ if (isPlainObject(broadcastId)) {
579
578
  instance.broadcastId = broadcastId.value;
580
579
  if (broadcastId.stripAnsi === false) {
581
580
  instance.supports('stripAnsi', false);
@@ -701,7 +700,7 @@ class Jimp extends Image {
701
700
  static applyMethod(instance, name, ...args) {
702
701
  const alias = getMethodName(name);
703
702
  if (!alias) {
704
- throw types.errorValue("Invalid method name", name);
703
+ throw errorValue("Invalid method name", name);
705
704
  }
706
705
  switch (alias) {
707
706
  case 'background':
@@ -738,7 +737,7 @@ class Jimp extends Image {
738
737
  case 'posterize':
739
738
  case 'opacity':
740
739
  case 'fade':
741
- if (types.isPlainObject(arg)) {
740
+ if (isPlainObject(arg)) {
742
741
  errorParameters(alias, args);
743
742
  }
744
743
  instance[alias](+arg);
@@ -748,8 +747,8 @@ class Jimp extends Image {
748
747
  instance[alias](arg);
749
748
  break;
750
749
  case 'print':
751
- if (types.isPlainObject(arg)) {
752
- if (types.isString(arg.font)) {
750
+ if (isPlainObject(arg)) {
751
+ if (isString(arg.font)) {
753
752
  arg.font = FONT_DATA[arg.font];
754
753
  }
755
754
  instance.print(arg);
@@ -759,7 +758,7 @@ class Jimp extends Image {
759
758
  }
760
759
  break;
761
760
  default:
762
- if (!types.isPlainObject(arg)) {
761
+ if (!isPlainObject(arg)) {
763
762
  errorParameters(alias, arg);
764
763
  }
765
764
  instance[alias](arg);
@@ -810,33 +809,33 @@ class Jimp extends Image {
810
809
  }
811
810
  async using(data, command) {
812
811
  if (this.aborted) {
813
- return types.createAbortError(true);
812
+ return createAbortError(true);
814
813
  }
815
814
  return new Promise(async (resolve, reject) => {
816
815
  const { host, file } = data;
817
816
  const localUri = host.getLocalUri(data);
818
817
  const mimeType = host.getMimeType(data);
819
818
  if (!localUri || !util.MIME_INPUT.has(mimeType)) {
820
- reject(types.errorValue("Unknown", !localUri ? 'URI' : 'MIME'));
819
+ reject(errorValue("Unknown", !localUri ? 'URI' : 'MIME'));
821
820
  return;
822
821
  }
823
822
  if (!this.canRead(localUri, { ownPermissionOnly: true })) {
824
- reject(types.errorValue("Not permitted to read file", localUri));
823
+ reject(errorValue("Not permitted to read file", localUri));
825
824
  return;
826
825
  }
827
826
  const [outputType, saveAs, outputAs] = util.parseFormat(command = command.trim(), mimeType);
828
827
  if (!outputType) {
829
- reject(types.errorValue("Invalid format", /^\w+/.exec(command)?.[0] || "Unknown"));
828
+ reject(errorValue("Invalid format", /^\w+/.exec(command)?.[0] || "Unknown"));
830
829
  return;
831
830
  }
832
831
  const replace = command.includes('@');
833
832
  const output = host.addCopy(data.getObject({ command, outputType }), saveAs, replace);
834
833
  if (!output) {
835
- reject(types.errorValue("Not able to copy file", outputType));
834
+ reject(errorValue("Not able to copy file", outputType));
836
835
  return;
837
836
  }
838
837
  if (!this.canWrite(output, { ownPermissionOnly: true })) {
839
- reject(types.errorValue("Not permitted to write file", output));
838
+ reject(errorValue("Not permitted to write file", output));
840
839
  return;
841
840
  }
842
841
  const startTime = process.hrtime();
@@ -871,7 +870,7 @@ class Jimp extends Image {
871
870
  let tempKey, tempFile;
872
871
  if (this.settings.cache && (file.etag || file.buffer)) {
873
872
  let buffer, ctimeMs;
874
- [buffer, tempFile] = getImageCache(this, tempKey = (file.etag || Image.asHash(file.buffer)) + command + mimeType);
873
+ [buffer, tempFile, ctimeMs] = getImageCache(this, tempKey = (file.etag || Image.asHash(file.buffer)) + command + mimeType);
875
874
  if (buffer) {
876
875
  const result = outputAs === 'webp' ? util.renameExt(output, 'webp', replace) : output;
877
876
  fs.writeFileSync(result, file.buffer = buffer);
@@ -916,7 +915,7 @@ class Jimp extends Image {
916
915
  if (!err && result) {
917
916
  finalize(result);
918
917
  }
919
- else if (types.isErrorCode(err, types.ERR_CODE.MODULE_NOT_FOUND)) {
918
+ else if (isErrorCode(err, ERR_CODE.MODULE_NOT_FOUND)) {
920
919
  resolve();
921
920
  }
922
921
  else {
@@ -974,7 +973,7 @@ class Jimp extends Image {
974
973
  }
975
974
  args.push('-o', util.normalizePath(webp));
976
975
  try {
977
- child_process.execFile(types.sanitizeCmd(await util.importBinary('gif2webp', webp_path), args), { shell: true, signal: this.signal, ...execOptions(this.settings) }, (err, stdout) => {
976
+ child_process.execFile(sanitizeCmd(await util.importBinary('gif2webp', webp_path), args), { shell: true, signal: this.signal, ...execOptions(this.settings) }, (err, stdout) => {
978
977
  if (!err) {
979
978
  this.addLog(4, stdout);
980
979
  finalize(webp);
@@ -1008,7 +1007,7 @@ class Jimp extends Image {
1008
1007
  .then(src => {
1009
1008
  rotateAnim(outputData);
1010
1009
  Promise.all(src.frames.map(async (frame) => {
1011
- const bitmap = bmp.encode(frame.bitmap).data;
1010
+ const bitmap = encode(frame.bitmap).data;
1012
1011
  const instance = await jimp.Jimp.read(bitmap);
1013
1012
  const handler = new JimpHandler(instance, this);
1014
1013
  return transformCommand(output, handler, outputData, Image.MIME_GIF);
@@ -1062,7 +1061,7 @@ class Jimp extends Image {
1062
1061
  await webp.load(host.getBuffer(file));
1063
1062
  if (!(webp.hasAnim && (outputType === Image.MIME_WEBP || outputType === Image.MIME_GIF))) {
1064
1063
  const buffer = Image.toABGR(await (!webp.hasAnim ? webp.getImageData() : webp.getFrameData(0)));
1065
- const bitmap = bmp.encode({ width: webp.width, height: webp.height, data: buffer }).data;
1064
+ const bitmap = encode({ width: webp.width, height: webp.height, data: buffer }).data;
1066
1065
  transformBuffer(bitmap);
1067
1066
  return true;
1068
1067
  }
@@ -1070,7 +1069,7 @@ class Jimp extends Image {
1070
1069
  startMessage();
1071
1070
  Promise.all(webp.frames.map(async (frame, index) => {
1072
1071
  const buffer = Image.toABGR(await webp.getFrameData(index));
1073
- const bitmap = bmp.encode({ width: frame.width, height: frame.height, data: buffer }).data;
1072
+ const bitmap = encode({ width: frame.width, height: frame.height, data: buffer }).data;
1074
1073
  const instance = await jimp.Jimp.read(bitmap);
1075
1074
  const handler = new JimpHandler(instance, this);
1076
1075
  handler.background(webp.anim.bgColor);
@@ -1155,7 +1154,7 @@ class Jimp extends Image {
1155
1154
  };
1156
1155
  const bmpFile = getTempPath(this, 'bmp');
1157
1156
  try {
1158
- child_process.execFile(types.sanitizeCmd(await util.importBinary('dwebp', this.settings.webp?.path), [util.normalizePath(localUri), '-bmp', '-o', util.normalizePath(bmpFile)]), { shell: true, signal: this.signal, ...execOptions(this.settings) }, err => {
1157
+ child_process.execFile(sanitizeCmd(await util.importBinary('dwebp', this.settings.webp?.path), [util.normalizePath(localUri), '-bmp', '-o', util.normalizePath(bmpFile)]), { shell: true, signal: this.signal, ...execOptions(this.settings) }, err => {
1159
1158
  if (!err) {
1160
1159
  transformBuffer(bmpFile);
1161
1160
  }
@@ -1181,11 +1180,11 @@ class Jimp extends Image {
1181
1180
  }
1182
1181
  }
1183
1182
  else {
1184
- if (core.WorkerChannel.hasPermission(file) && this.parseWorker(outputData, outputType)) {
1183
+ if (WorkerChannel.hasPermission(file) && this.parseWorker(outputData, outputType)) {
1185
1184
  try {
1186
1185
  let timer = null;
1187
1186
  const failed = (message) => {
1188
- reject(types.errorMessage("jimp", message, localUri));
1187
+ reject(errorMessage("jimp", message, localUri));
1189
1188
  };
1190
1189
  const worker = WORKER_JIMP.sendObject({ data: file.buffer || localUri, commandData: outputData, outputType, output, options: this.getEncodeOptions() }, [], (value) => {
1191
1190
  if (timer) {
@@ -1203,7 +1202,7 @@ class Jimp extends Image {
1203
1202
  timer = setTimeout(() => {
1204
1203
  void worker.terminate();
1205
1204
  failed("Worker timeout was exceeded");
1206
- }, core.WorkerGroup.checkTimeout(file.worker, true));
1205
+ }, WorkerGroup.checkTimeout(file.worker, true));
1207
1206
  }
1208
1207
  return;
1209
1208
  }
@@ -1226,4 +1225,5 @@ class Jimp extends Image {
1226
1225
  return this.module.settings ||= {};
1227
1226
  }
1228
1227
  }
1228
+
1229
1229
  module.exports = Jimp;
package/package.json CHANGED
@@ -1,12 +1,9 @@
1
1
  {
2
2
  "name": "@pi-r/jimp",
3
- "version": "0.11.3",
3
+ "version": "0.12.1",
4
4
  "description": "Jimp V1 image constructor for E-mc.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
7
- "publishConfig": {
8
- "access": "public"
9
- },
10
7
  "repository": {
11
8
  "type": "git",
12
9
  "url": "git+https://github.com/anpham6/pi-r2.git",
@@ -20,9 +17,9 @@
20
17
  "license": "MIT",
21
18
  "homepage": "https://github.com/anpham6/pi-r2#readme",
22
19
  "dependencies": {
23
- "@e-mc/core": "^0.13.10",
24
- "@e-mc/image": "^0.13.10",
25
- "@e-mc/types": "^0.13.10",
20
+ "@e-mc/core": "^0.14.1",
21
+ "@e-mc/image": "^0.14.1",
22
+ "@e-mc/types": "^0.14.1",
26
23
  "@jimp/utils": "1.6.0",
27
24
  "bmp-js": "^0.1.0",
28
25
  "gifwrap": "^0.10.1",
package/util.js CHANGED
@@ -1,9 +1,9 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
- const path = require("node:path");
4
- const fs = require("node:fs");
5
- const types = require("@e-mc/types");
6
- const Image = require("@e-mc/image");
3
+ const path = require('node:path');
4
+ const fs = require('node:fs');
5
+ const { importESM, renameExt: renameExt_ } = require('@e-mc/types');
6
+ const Image = require('@e-mc/image');
7
7
  const MIME_INPUT = new Set([
8
8
  Image.MIME_PNG,
9
9
  Image.MIME_JPEG,
@@ -64,12 +64,12 @@ function detectExt(mimeType, webp) {
64
64
  }
65
65
  }
66
66
  function renameExt(output, ext, replace) {
67
- let result = types.renameExt(output.replace('.__copy__.', '.'), ext);
67
+ let result = renameExt_(output.replace('.__copy__.', '.'), ext);
68
68
  if (!replace) {
69
69
  const pathname = result;
70
70
  let i = 0;
71
71
  while (Image.isPath(result)) {
72
- result = pathname.substring(0, pathname.lastIndexOf('.') + 1) + `(${++i}).` + ext;
72
+ result = pathname.slice(0, pathname.lastIndexOf('.') + 1) + `(${++i}).` + ext;
73
73
  }
74
74
  }
75
75
  return result;
@@ -83,7 +83,7 @@ async function importBinary(name, pathname) {
83
83
  const bin = path.join(pathname, name);
84
84
  return fs.existsSync(bin) ? bin : path.join(pathname, 'bin', name);
85
85
  }
86
- return types.importESM(name + '-bin', true);
86
+ return importESM(name + '-bin', true);
87
87
  }
88
88
  function showInputType(value, outputType, finalAs) {
89
89
  if (finalAs) {
package/worker/jimp.js CHANGED
@@ -1,41 +1,40 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
- var node_worker_threads = require('node:worker_threads');
4
- var jimp = require('jimp');
5
- var types = require('@e-mc/types');
6
-
7
- const Image = require("@e-mc/image");
8
- const JimpApp = require("@pi-r/jimp");
9
- const PORT = node_worker_threads.workerData[0];
10
- node_worker_threads.parentPort.on('message', (value) => {
3
+ const { parentPort, workerData } = require('node:worker_threads');
4
+ const { Jimp } = require('jimp');
5
+ const Image = require('@e-mc/image');
6
+ const { errorMessage, isString } = require('@e-mc/types');
7
+ const Main = require('@pi-r/jimp');
8
+ const PORT = workerData[0];
9
+ parentPort.on('message', (value) => {
11
10
  const { data, commandData, output, options } = value;
12
- jimp.Jimp.read(typeof data === 'string' ? data : Image.asBuffer(data))
11
+ Jimp.read(typeof data === 'string' ? data : Image.asBuffer(data))
13
12
  .then(async (img) => {
14
13
  const { method, resize, crop, rotate, opacity = -1 } = commandData;
15
14
  if (method) {
16
15
  for (const [name, args = []] of method) {
17
16
  if (name === 'composite') {
18
17
  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);
18
+ if (isString(src) && typeof x === 'number' && typeof y === 'number') {
19
+ img.composite(await Jimp.read(src), x, y, opts);
21
20
  }
22
21
  else {
23
- throw types.errorMessage(name, "Invalid parameters", JSON.stringify(value));
22
+ throw errorMessage(name, "Invalid parameters", JSON.stringify(value));
24
23
  }
25
24
  }
26
25
  else {
27
- JimpApp.applyMethod(img, name, ...args);
26
+ Main.applyMethod(img, name, ...args);
28
27
  }
29
28
  }
30
29
  }
31
30
  if (resize) {
32
- JimpApp.applyResize(img, resize);
31
+ Main.applyResize(img, resize);
33
32
  }
34
33
  if (crop) {
35
- JimpApp.applyCrop(img, crop);
34
+ Main.applyCrop(img, crop);
36
35
  }
37
36
  if (rotate) {
38
- JimpApp.applyRotate(img, rotate);
37
+ Main.applyRotate(img, rotate);
39
38
  }
40
39
  if (opacity >= 0) {
41
40
  img.opacity(opacity);