apexify.js 1.2.8 → 2.1.0
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 +583 -361
- package/declare.d.ts +117 -1
- package/index.js +1 -4
- package/lib/canvas/ApexPainter.js +52 -57
- package/lib/database/NanoDB.js +353 -330
- package/lib/discord/events/starter.js +88 -19
- package/lib/general-functions/utils.js +19 -0
- package/lib/utils.js +1 -1
- package/package.json +47 -5
package/declare.d.ts
CHANGED
|
@@ -1 +1,117 @@
|
|
|
1
|
-
declare module
|
|
1
|
+
declare module "apexify.js" {
|
|
2
|
+
class ApexPainter {
|
|
3
|
+
constructor(...args: any[]);
|
|
4
|
+
[key: string]: any;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
class apexAI {
|
|
8
|
+
constructor(...args: any[]);
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const ecoSystem: any;
|
|
13
|
+
const adminUser: any;
|
|
14
|
+
const blackList: any;
|
|
15
|
+
const whiteList: any;
|
|
16
|
+
|
|
17
|
+
function apexImagine(...args: any[]): any;
|
|
18
|
+
function ApexChat(...args: any[]): any;
|
|
19
|
+
|
|
20
|
+
const typeWriter: any;
|
|
21
|
+
const starter: any;
|
|
22
|
+
const previousCommand: any;
|
|
23
|
+
const resumeCommand: any;
|
|
24
|
+
const skipCommand: any;
|
|
25
|
+
const stopCommand: any;
|
|
26
|
+
const playCommand: any;
|
|
27
|
+
|
|
28
|
+
class PermissionChecker {
|
|
29
|
+
constructor(...args: any[]);
|
|
30
|
+
[key: string]: any;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
class Paginator {
|
|
34
|
+
constructor(...args: any[]);
|
|
35
|
+
[key: string]: any;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
class SelectMenuManager {
|
|
39
|
+
constructor(...args: any[]);
|
|
40
|
+
[key: string]: any;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
class ButtonManager {
|
|
44
|
+
constructor(...args: any[]);
|
|
45
|
+
[key: string]: any;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const cooldown: any;
|
|
49
|
+
|
|
50
|
+
export const ApexPainter: ApexPainter;
|
|
51
|
+
export const apexAI: apexAI;
|
|
52
|
+
export const ApexImagine: ApexImagine;
|
|
53
|
+
export const ApexChat: ApexChat;
|
|
54
|
+
export const NanoDb: any;
|
|
55
|
+
export const mongoConnect: any;
|
|
56
|
+
export const getDb: any;
|
|
57
|
+
export const initializeDb: any;
|
|
58
|
+
export const save: any;
|
|
59
|
+
export const aggregate: any;
|
|
60
|
+
export const createTable: any;
|
|
61
|
+
export const countDocs: any;
|
|
62
|
+
export const dataSize: any;
|
|
63
|
+
export const distinct: any;
|
|
64
|
+
export const drop: any;
|
|
65
|
+
export const find: any;
|
|
66
|
+
export const geoNear: any;
|
|
67
|
+
export const listIndexes: any;
|
|
68
|
+
export const listCollections: any;
|
|
69
|
+
export const remove: any;
|
|
70
|
+
export const removeMany: any;
|
|
71
|
+
export const removeManyExcept: any;
|
|
72
|
+
export const removeSpecific: any;
|
|
73
|
+
export const searchMany: any;
|
|
74
|
+
export const textSearch: any;
|
|
75
|
+
export const migrateData: any;
|
|
76
|
+
export const migrateAndPrune: any;
|
|
77
|
+
export const updateData: any;
|
|
78
|
+
export const updateAll: any;
|
|
79
|
+
export const updateAllExcept: any;
|
|
80
|
+
export const userTemplate: any;
|
|
81
|
+
export const guildInfo: any;
|
|
82
|
+
export const setserverCounter: any;
|
|
83
|
+
export const employeeInfo: any;
|
|
84
|
+
export const gameCount: any;
|
|
85
|
+
export const setGameCount: any;
|
|
86
|
+
export const musicTrack: any;
|
|
87
|
+
export const recipeInfo: any;
|
|
88
|
+
export const productReview: any;
|
|
89
|
+
export const orderInfo: any;
|
|
90
|
+
export const forumPost: any;
|
|
91
|
+
export const xpCount: any;
|
|
92
|
+
export const xpConfig: any;
|
|
93
|
+
export const userEco: any;
|
|
94
|
+
export const productInfo: any;
|
|
95
|
+
export const blogPost: any;
|
|
96
|
+
export const eventInfo: any;
|
|
97
|
+
export const shopItem: any;
|
|
98
|
+
export const contactInfo: any;
|
|
99
|
+
export const roleMenu: any;
|
|
100
|
+
export const ecoSystem: any;
|
|
101
|
+
export const adminUser: any;
|
|
102
|
+
export const blackList: any;
|
|
103
|
+
export const whiteList: any;
|
|
104
|
+
export const cooldown: any;
|
|
105
|
+
export const ButtonManager: any;
|
|
106
|
+
export const SelectMenuManager: any;
|
|
107
|
+
export const Paginator: any;
|
|
108
|
+
export const PermissionChecker: any;
|
|
109
|
+
export const playCommand: any;
|
|
110
|
+
export const stopCommand: any;
|
|
111
|
+
export const skipCommand: any;
|
|
112
|
+
export const resumeCommand: any;
|
|
113
|
+
export const previousCommand: any;
|
|
114
|
+
export const starter: any;
|
|
115
|
+
export const typeWriter: any;
|
|
116
|
+
}
|
|
117
|
+
|
package/index.js
CHANGED
|
@@ -36,11 +36,8 @@ axios_1.default
|
|
|
36
36
|
"Error: Please update apexify.js to the latest version (".concat(version, ").") +
|
|
37
37
|
RESET);
|
|
38
38
|
}
|
|
39
|
-
})
|
|
40
|
-
.catch(function (error) { });
|
|
39
|
+
}).catch(function (error) { });
|
|
41
40
|
|
|
42
|
-
"use strict";
|
|
43
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
41
|
exports.ApexChat = exports.ApexImagine = exports.adminUser = exports.ecoSystem = exports.roleMenu = exports.contactInfo = exports.shopItem = exports.eventInfo = exports.blogPost = exports.productInfo = exports.userEco = exports.xpConfig = exports.xpCount = exports.forumPost = exports.orderInfo = exports.productReview = exports.recipeInfo = exports.musicTrack = exports.setGameCount = exports.gameCount = exports.employeeInfo = exports.setserverCounter = exports.guildInfo = exports.userTemplate = exports.updateAllExcept = exports.updateAll = exports.updateData = exports.migrateAndPrune = exports.migrateData = exports.textSearch = exports.searchMany = exports.removeSpecific = exports.removeManyExcept = exports.removeMany = exports.remove = exports.listCollections = exports.listIndexes = exports.geoNear = exports.find = exports.drop = exports.distinct = exports.dataSize = exports.countDocs = exports.createTable = exports.aggregate = exports.save = exports.initializeDb = exports.getDb = exports.mongoConnect = exports.NanoDb = exports.apexAI = exports.ApexPainter = void 0;
|
|
45
42
|
exports.typeWriter = exports.starter = exports.previousCommand = exports.resumeCommand = exports.skipCommand = exports.stopCommand = exports.playCommand = exports.PermissionChecker = exports.Paginator = exports.SelectMenuManager = exports.ButtonManager = exports.cooldown = exports.whiteList = exports.blackList = void 0;
|
|
46
43
|
var utils_1 = require("./lib/utils");
|
|
@@ -8,7 +8,7 @@ const FormData = require("form-data");
|
|
|
8
8
|
const GIFEncoder = require("gifencoder");
|
|
9
9
|
const stream = require("stream");
|
|
10
10
|
|
|
11
|
-
class
|
|
11
|
+
class ApexPainter {
|
|
12
12
|
constructor() {
|
|
13
13
|
this.defaultTextOptions = {
|
|
14
14
|
text: "Add Text Here",
|
|
@@ -178,15 +178,12 @@ class PaintImage {
|
|
|
178
178
|
return true;
|
|
179
179
|
}
|
|
180
180
|
|
|
181
|
-
//////////drawing image using canvas
|
|
182
181
|
async drawImages(imagesOptions, canvasOptions, baseDir) {
|
|
183
|
-
// Merge canvas options with default options
|
|
184
182
|
const mergedCanvasOptions = this.mergeOptions(
|
|
185
183
|
this.defaultCanvasOptions,
|
|
186
184
|
canvasOptions,
|
|
187
185
|
);
|
|
188
186
|
|
|
189
|
-
// Validate canvas options
|
|
190
187
|
if (!mergedCanvasOptions || typeof mergedCanvasOptions !== "object") {
|
|
191
188
|
throw new Error(
|
|
192
189
|
"Invalid canvas options. Provide a valid object for canvas configuration.",
|
|
@@ -227,17 +224,15 @@ this.drawRoundedRect(
|
|
|
227
224
|
);
|
|
228
225
|
|
|
229
226
|
ctx.clip();
|
|
230
|
-
|
|
227
|
+
|
|
231
228
|
ctx.drawImage(customBgImage, 0, 0);
|
|
232
229
|
} else {
|
|
233
|
-
// Create a canvas based on the specified width and height
|
|
234
230
|
canvas = createCanvas(
|
|
235
231
|
mergedCanvasOptions.width,
|
|
236
232
|
mergedCanvasOptions.height,
|
|
237
233
|
);
|
|
238
234
|
ctx = canvas.getContext("2d");
|
|
239
235
|
|
|
240
|
-
// Customize the canvas drawing based on other options (background color, gradient, etc.)
|
|
241
236
|
if (mergedCanvasOptions.backgroundGradient) {
|
|
242
237
|
const gradient = this.createGradient(
|
|
243
238
|
ctx,
|
|
@@ -259,7 +254,6 @@ ctx.drawImage(customBgImage, 0, 0);
|
|
|
259
254
|
ctx.fill();
|
|
260
255
|
} else if (mergedCanvasOptions.backgroundColor) {
|
|
261
256
|
if (mergedCanvasOptions.borderRadius) {
|
|
262
|
-
// Draw a rounded rectangle for the background
|
|
263
257
|
this.drawRoundedRect(
|
|
264
258
|
ctx,
|
|
265
259
|
mergedCanvasOptions.x,
|
|
@@ -282,18 +276,15 @@ ctx.drawImage(customBgImage, 0, 0);
|
|
|
282
276
|
}
|
|
283
277
|
}
|
|
284
278
|
|
|
285
|
-
// Draw each image on the canvas if options are provided
|
|
286
279
|
if (imagesOptions && imagesOptions.length > 0) {
|
|
287
280
|
for (const imageOptions of imagesOptions) {
|
|
288
281
|
await this.drawSingleImage(ctx, imageOptions, baseDir);
|
|
289
282
|
}
|
|
290
283
|
}
|
|
291
|
-
|
|
292
|
-
// Return the buffer directly
|
|
284
|
+
|
|
293
285
|
return canvas.toBuffer("image/png");
|
|
294
|
-
}
|
|
286
|
+
}
|
|
295
287
|
|
|
296
|
-
///////Drawing single images
|
|
297
288
|
async drawSingleImage(ctx, imageOptions, baseDir) {
|
|
298
289
|
const mergedImageOptions = this.mergeOptions(
|
|
299
290
|
this.defaultImageOptions,
|
|
@@ -301,7 +292,6 @@ ctx.drawImage(customBgImage, 0, 0);
|
|
|
301
292
|
);
|
|
302
293
|
this.validateImageOptions(imageOptions);
|
|
303
294
|
|
|
304
|
-
// Check if the source is a shape name
|
|
305
295
|
if (
|
|
306
296
|
mergedImageOptions.source &&
|
|
307
297
|
this.isShapeName(mergedImageOptions.source)
|
|
@@ -335,10 +325,8 @@ ctx.drawImage(customBgImage, 0, 0);
|
|
|
335
325
|
}
|
|
336
326
|
}
|
|
337
327
|
|
|
338
|
-
// Save the initial context state
|
|
339
328
|
ctx.save();
|
|
340
329
|
|
|
341
|
-
// Apply shadow if provided
|
|
342
330
|
if (
|
|
343
331
|
mergedImageOptions.shadow &&
|
|
344
332
|
mergedImageOptions.shadow.offsetX &&
|
|
@@ -347,7 +335,6 @@ ctx.drawImage(customBgImage, 0, 0);
|
|
|
347
335
|
ctx.globalAlpha = mergedImageOptions.shadow.opacity || null;
|
|
348
336
|
ctx.filter = `blur(${mergedImageOptions.shadow.blur || null}px)`;
|
|
349
337
|
|
|
350
|
-
// Draw a rounded rectangle as a shadow
|
|
351
338
|
const shadowX =
|
|
352
339
|
mergedImageOptions.x + (mergedImageOptions.shadow.offsetX || 0);
|
|
353
340
|
const shadowY =
|
|
@@ -366,11 +353,9 @@ ctx.drawImage(customBgImage, 0, 0);
|
|
|
366
353
|
ctx.fill();
|
|
367
354
|
}
|
|
368
355
|
|
|
369
|
-
// Reset filter and opacity properties
|
|
370
356
|
ctx.filter = "none";
|
|
371
357
|
ctx.globalAlpha = 1;
|
|
372
358
|
|
|
373
|
-
// Draw the actual image
|
|
374
359
|
this.drawRoundedImage(
|
|
375
360
|
ctx,
|
|
376
361
|
image,
|
|
@@ -381,10 +366,8 @@ ctx.drawImage(customBgImage, 0, 0);
|
|
|
381
366
|
mergedImageOptions.borderRadius || 0,
|
|
382
367
|
);
|
|
383
368
|
|
|
384
|
-
// Restore the context state
|
|
385
369
|
ctx.restore();
|
|
386
370
|
|
|
387
|
-
// Apply stroke if provided
|
|
388
371
|
if (
|
|
389
372
|
mergedImageOptions.stroke &&
|
|
390
373
|
mergedImageOptions.stroke.color &&
|
|
@@ -393,7 +376,6 @@ ctx.drawImage(customBgImage, 0, 0);
|
|
|
393
376
|
ctx.strokeStyle = mergedImageOptions.stroke.color || "transparent"; // Change color as needed
|
|
394
377
|
ctx.lineWidth = mergedImageOptions.stroke.width || 1;
|
|
395
378
|
|
|
396
|
-
// Draw the rounded rectangle for stroke
|
|
397
379
|
this.drawRoundedRect(
|
|
398
380
|
ctx,
|
|
399
381
|
mergedImageOptions.x,
|
|
@@ -409,7 +391,6 @@ ctx.drawImage(customBgImage, 0, 0);
|
|
|
409
391
|
}
|
|
410
392
|
|
|
411
393
|
isShapeName(source) {
|
|
412
|
-
// Check if the source is a valid shape name
|
|
413
394
|
const validShapes = ["square", "circle", "triangle", "rectangle"];
|
|
414
395
|
return validShapes.includes(source.toLowerCase());
|
|
415
396
|
}
|
|
@@ -431,10 +412,8 @@ ctx.drawImage(customBgImage, 0, 0);
|
|
|
431
412
|
} = shapeOptions;
|
|
432
413
|
const isFilled = filled !== undefined ? filled : true;
|
|
433
414
|
|
|
434
|
-
// Save the initial context state
|
|
435
415
|
ctx.save();
|
|
436
416
|
|
|
437
|
-
// Apply shadow if provided
|
|
438
417
|
if (shadow && shadow.offsetX && shadow.offsetY) {
|
|
439
418
|
ctx.globalAlpha = shadow.opacity || null;
|
|
440
419
|
ctx.filter = `blur(${shadow.blur || null}px)`;
|
|
@@ -455,7 +434,6 @@ ctx.drawImage(customBgImage, 0, 0);
|
|
|
455
434
|
ctx.fill();
|
|
456
435
|
}
|
|
457
436
|
|
|
458
|
-
// Reset filter property
|
|
459
437
|
ctx.filter = "none";
|
|
460
438
|
ctx.globalAlpha = 1;
|
|
461
439
|
|
|
@@ -511,7 +489,6 @@ ctx.drawImage(customBgImage, 0, 0);
|
|
|
511
489
|
}
|
|
512
490
|
ctx.closePath();
|
|
513
491
|
break;
|
|
514
|
-
// Add cases for other shapes
|
|
515
492
|
default:
|
|
516
493
|
console.error(`Unsupported shape: ${source}`);
|
|
517
494
|
}
|
|
@@ -553,7 +530,7 @@ ctx.drawImage(customBgImage, 0, 0);
|
|
|
553
530
|
}
|
|
554
531
|
|
|
555
532
|
ctx.restore();
|
|
556
|
-
}
|
|
533
|
+
}
|
|
557
534
|
|
|
558
535
|
async addText(textOptionsArray, buffer, baseDir) {
|
|
559
536
|
try {
|
|
@@ -562,14 +539,11 @@ ctx.drawImage(customBgImage, 0, 0);
|
|
|
562
539
|
const canvas = createCanvas(existingImage.width, existingImage.height);
|
|
563
540
|
const ctx = canvas.getContext("2d");
|
|
564
541
|
|
|
565
|
-
// Draw the existing image buffer onto the new canvas
|
|
566
542
|
ctx.drawImage(existingImage, 0, 0);
|
|
567
543
|
|
|
568
|
-
// Loop through each text option and draw it on the canvas
|
|
569
544
|
for (const textOptions of textOptionsArray) {
|
|
570
545
|
this.validateTextOptions(textOptions);
|
|
571
546
|
|
|
572
|
-
// Merge text options with default options
|
|
573
547
|
const mergedTextOptions = this.mergeOptions(
|
|
574
548
|
this.defaultTextOptions,
|
|
575
549
|
textOptions,
|
|
@@ -587,14 +561,11 @@ ctx.drawImage(customBgImage, 0, 0);
|
|
|
587
561
|
ctx.font = `${mergedTextOptions.fontSize}px ${mergedTextOptions.fontName || "Arial"}`;
|
|
588
562
|
}
|
|
589
563
|
|
|
590
|
-
// Draw the text on top of the existing image
|
|
591
564
|
this.drawText(ctx, mergedTextOptions);
|
|
592
565
|
}
|
|
593
566
|
|
|
594
|
-
// Return the buffer with both image and text
|
|
595
567
|
return canvas.toBuffer("image/png");
|
|
596
568
|
} catch (error) {
|
|
597
|
-
// Handle the case where the buffer is not a valid image
|
|
598
569
|
console.error("Error loading existing image:", error);
|
|
599
570
|
throw new Error("Invalid image buffer");
|
|
600
571
|
}
|
|
@@ -606,14 +577,15 @@ ctx.drawImage(customBgImage, 0, 0);
|
|
|
606
577
|
textOptions,
|
|
607
578
|
);
|
|
608
579
|
|
|
609
|
-
// Save the initial context state
|
|
610
580
|
ctx.save();
|
|
611
|
-
|
|
612
|
-
|
|
581
|
+
let boldness = '';
|
|
582
|
+
if (mergedTextOptions.bold) {
|
|
583
|
+
boldness = 'bold';
|
|
584
|
+
}
|
|
585
|
+
ctx.font = `${boldness}${mergedTextOptions.fontSize}px ${mergedTextOptions.fontName}`;
|
|
613
586
|
ctx.textAlign = mergedTextOptions.textAlign;
|
|
614
587
|
ctx.textBaseline = mergedTextOptions.textBaseline;
|
|
615
588
|
|
|
616
|
-
// Apply shadow if provided
|
|
617
589
|
if (
|
|
618
590
|
mergedTextOptions.shadow &&
|
|
619
591
|
mergedTextOptions.shadow.offsetX !== undefined &&
|
|
@@ -625,17 +597,25 @@ ctx.drawImage(customBgImage, 0, 0);
|
|
|
625
597
|
ctx.shadowBlur = mergedTextOptions.shadow.blur || 0;
|
|
626
598
|
}
|
|
627
599
|
|
|
628
|
-
// Set fill color
|
|
629
600
|
ctx.fillStyle = mergedTextOptions.color;
|
|
630
601
|
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
602
|
+
if (mergedTextOptions.maxWidth) {
|
|
603
|
+
this.drawWrappedText(
|
|
604
|
+
ctx,
|
|
605
|
+
mergedTextOptions.text,
|
|
606
|
+
mergedTextOptions.x,
|
|
607
|
+
mergedTextOptions.y,
|
|
608
|
+
mergedTextOptions.maxWidth,
|
|
609
|
+
mergedTextOptions
|
|
610
|
+
);
|
|
611
|
+
} else {
|
|
612
|
+
ctx.fillText(
|
|
613
|
+
mergedTextOptions.text,
|
|
614
|
+
mergedTextOptions.x,
|
|
615
|
+
mergedTextOptions.y,
|
|
616
|
+
);
|
|
617
|
+
}
|
|
637
618
|
|
|
638
|
-
// Draw the text stroke if provided
|
|
639
619
|
if (
|
|
640
620
|
mergedTextOptions.stroke &&
|
|
641
621
|
mergedTextOptions.stroke.color &&
|
|
@@ -644,7 +624,6 @@ ctx.drawImage(customBgImage, 0, 0);
|
|
|
644
624
|
ctx.strokeStyle = mergedTextOptions.stroke.color;
|
|
645
625
|
ctx.lineWidth = mergedTextOptions.stroke.width;
|
|
646
626
|
|
|
647
|
-
// Draw the text stroke
|
|
648
627
|
ctx.strokeText(
|
|
649
628
|
mergedTextOptions.text,
|
|
650
629
|
mergedTextOptions.x,
|
|
@@ -654,6 +633,29 @@ ctx.drawImage(customBgImage, 0, 0);
|
|
|
654
633
|
ctx.restore();
|
|
655
634
|
}
|
|
656
635
|
|
|
636
|
+
drawWrappedText(ctx, text, x, y, maxWidth, mergedTextOptions) {
|
|
637
|
+
const words = text.split(' ');
|
|
638
|
+
let currentLine = '';
|
|
639
|
+
|
|
640
|
+
for (let n = 0; n < words.length; n++) {
|
|
641
|
+
const testLine = currentLine + words[n] + ' ';
|
|
642
|
+
const metrics = ctx.measureText(testLine);
|
|
643
|
+
const testWidth = metrics.width;
|
|
644
|
+
|
|
645
|
+
if (testWidth > maxWidth && n > 0) {
|
|
646
|
+
const adjustedY = y + (mergedTextOptions.lineHeight || mergedTextOptions.fontSize) / 2;
|
|
647
|
+
ctx.fillText(currentLine.trim(), x, adjustedY);
|
|
648
|
+
currentLine = words[n] + ' ';
|
|
649
|
+
y += mergedTextOptions.lineHeight || mergedTextOptions.fontSize;
|
|
650
|
+
} else {
|
|
651
|
+
currentLine = testLine;
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
const adjustedY = y + (mergedTextOptions.lineHeight || mergedTextOptions.fontSize) / 2;
|
|
656
|
+
ctx.fillText(currentLine.trim(), x, adjustedY);
|
|
657
|
+
}
|
|
658
|
+
|
|
657
659
|
mergeOptions(defaultOptions, userOptions) {
|
|
658
660
|
const mergedOptions = { ...defaultOptions };
|
|
659
661
|
|
|
@@ -789,7 +791,6 @@ ctx.drawImage(customBgImage, 0, 0);
|
|
|
789
791
|
}
|
|
790
792
|
}
|
|
791
793
|
|
|
792
|
-
////other options for image manipulations
|
|
793
794
|
async loadImageFromPathOrURL(imagePath, baseDir) {
|
|
794
795
|
try {
|
|
795
796
|
if (!imagePath) {
|
|
@@ -819,7 +820,6 @@ ctx.drawImage(customBgImage, 0, 0);
|
|
|
819
820
|
}
|
|
820
821
|
}
|
|
821
822
|
|
|
822
|
-
/// Resizing an image
|
|
823
823
|
async resize(resizeOptions, baseDir) {
|
|
824
824
|
try {
|
|
825
825
|
if (!resizeOptions.imagePath) {
|
|
@@ -835,7 +835,7 @@ ctx.drawImage(customBgImage, 0, 0);
|
|
|
835
835
|
|
|
836
836
|
return resizedBuffer;
|
|
837
837
|
}
|
|
838
|
-
|
|
838
|
+
|
|
839
839
|
if (resizeOptions.imagePath.startsWith("http")) {
|
|
840
840
|
if (baseDir) {
|
|
841
841
|
throw new Error("No need for baseDir when using an image URL.");
|
|
@@ -861,8 +861,6 @@ ctx.drawImage(customBgImage, 0, 0);
|
|
|
861
861
|
}
|
|
862
862
|
}
|
|
863
863
|
|
|
864
|
-
|
|
865
|
-
/////converter
|
|
866
864
|
async imageConverter(imagePath, newExtension, baseDir) {
|
|
867
865
|
try {
|
|
868
866
|
let image;
|
|
@@ -893,7 +891,6 @@ ctx.drawImage(customBgImage, 0, 0);
|
|
|
893
891
|
}
|
|
894
892
|
}
|
|
895
893
|
|
|
896
|
-
/////image filters
|
|
897
894
|
async processImage(imagePath, filters, baseDir = null) {
|
|
898
895
|
try {
|
|
899
896
|
let jimpImage;
|
|
@@ -1031,7 +1028,6 @@ ctx.drawImage(customBgImage, 0, 0);
|
|
|
1031
1028
|
}
|
|
1032
1029
|
}
|
|
1033
1030
|
|
|
1034
|
-
////background removal
|
|
1035
1031
|
async bgRemoval(options) {
|
|
1036
1032
|
const apiKey = options.apiKey;
|
|
1037
1033
|
const formData = new FormData();
|
|
@@ -1076,7 +1072,7 @@ if (!lowerCaseImageUrl.endsWith(".png") && !lowerCaseImageUrl.endsWith(".jpg"))
|
|
|
1076
1072
|
|
|
1077
1073
|
formData.append("bg_color", options.bg_color || null);
|
|
1078
1074
|
formData.append("bg_image_url", options.bg_image_url || null);
|
|
1079
|
-
|
|
1075
|
+
|
|
1080
1076
|
try {
|
|
1081
1077
|
const response = await axios({
|
|
1082
1078
|
method: "post",
|
|
@@ -1125,7 +1121,6 @@ if (!lowerCaseImageUrl.endsWith(".png") && !lowerCaseImageUrl.endsWith(".jpg"))
|
|
|
1125
1121
|
}
|
|
1126
1122
|
}
|
|
1127
1123
|
|
|
1128
|
-
/////Draw gif
|
|
1129
1124
|
async createGIF(images, options = {}) {
|
|
1130
1125
|
async function resizeImage(image, targetWidth, targetHeight) {
|
|
1131
1126
|
const canvas = createCanvas(targetWidth, targetHeight);
|
|
@@ -1396,4 +1391,4 @@ if (!lowerCaseImageUrl.endsWith(".png") && !lowerCaseImageUrl.endsWith(".jpg"))
|
|
|
1396
1391
|
}
|
|
1397
1392
|
}
|
|
1398
1393
|
|
|
1399
|
-
module.exports = {
|
|
1394
|
+
module.exports = { ApexPainter };
|