17
17
18
18
- [ Installation] ( #installation )
19
19
- [ NPM Module Required] ( #npm-module-required )
20
+ - [ Canvas Dependencies Required] ( #canvas-dependencies-required )
20
21
- [ Documentation] ( #documentation )
21
22
- [ Image Format] ( #image-format )
22
23
- [ Align Format] ( #align-format )
25
26
## Installation Guide
26
27
- Download the release from [ here] ( https://github.com/LeonZ2019/dbm-canvas/releases )
27
28
- Extract files and folder to your bot's directory actions folder
29
+ - Get all canvas dependencies from [ here] ( #canvas-dependencies-required )
28
30
29
31
## NPM Module Required
30
32
- Basic Section
44
46
- [x] chalk
45
47
- [x] node-fetch
46
48
49
+ ## Canvas Dependencies Required
50
+ - [x] gifski https://github.com/ImageOptim/gifski/releases
51
+ - [x] dwebp https://developers.google.com/speed/webp/download
52
+ - [x] palette.js https://github.com/google/palette.js/blob/master/palette.js
53
+
47
54
## Documentation
48
55
### Basic Image Manipulate
49
56
* [ Create Image] ( #create-image )
59
66
* [ Generate Graph] ( #generate-graph )
60
67
### Others
61
68
* [ Image Buffer] ( #image-buffer )
62
- * [ GIF Image Buffer ] ( #gif -image-buffer )
69
+ * [ Save Image Local ] ( #save -image-local )
63
70
* [ Discord Attachment] ( #discord-attachment )
64
71
* [ Image Bridge] ( #image-bridge )
65
72
@@ -72,8 +79,9 @@ Image type support png, jpg, gif webp(still image) and of course base64 image, i
72
79
- [ Object] ** ` options ` **
73
80
- [ Integer] ** ` delay ` ** Delay for gif if image is animated
74
81
- [ Integer] ** ` loop ` ** Loop for gif if image is animated
82
+ - [ Integer] ** ` overlap ` ** Redraw gif by previous frame, value should be ` 0 ` - ` 2 ` , ` 0 ` is Auto, ` 1 ` is True and ` 2 ` is False
75
83
```
76
- this.Canvas.createImage('https://www.website.com/image_**.png', { delay: 100, loop: 0 }).then((image) => {
84
+ this.Canvas.createImage('https://www.website.com/image_**.png', { delay: 100, loop: 0, overlap: 0 }).then((image) => {
77
85
})
78
86
79
87
// or with async/await:
@@ -244,22 +252,21 @@ this.Canvas.generateChart('bar', 800, 400, 'Score', ['Team Red', 'Team Blue', 'T
244
252
``` js
245
253
DBM .Actions .Canvas .toBuffer (img) => [Buffer]
246
254
```
247
- Convert still image to buffer
255
+ Convert gif/ still image to buffer
248
256
- [ Image] ** ` img ` ** image generate from canvas
249
257
``` js
250
258
const buffer = DBM .Actions .Canvas .toBuffer (img)
251
- require (' fs' ).writeFileSync (' resources\i mage.png' , buffer)
252
259
```
253
260
254
- ## GIF Image Buffer
261
+ ## Save Image Local
255
262
``` js
256
- DBM .Actions .Canvas .GifToBuffer (img) => [Buffer]
263
+ DBM .Actions .Canvas .Export (img, destination)
257
264
```
258
- Convert gif or animated image to buffer
265
+ Save gif/still image to local directly
259
266
- [ Image] ** ` img ` ** image generate from canvas
267
+ - [ String] ** ` destination ` ** local path for image
260
268
``` js
261
- const buffer = DBM .Actions .Canvas .GifToBuffer (img)
262
- require (' fs' ).writeFileSync (' resources\i mage.gif' , buffer)
269
+ const buffer = DBM .Actions .Canvas .Export (img, ' resources\\ export.png' )
263
270
```
264
271
265
272
## Discord Attachment
@@ -291,18 +298,22 @@ const image = await this.Canvas.bridge(img, 0)
291
298
292
299
## Image Format
293
300
- Still Image
294
- - [ String] Type
295
- - Store in ` base64 ` format, it should start with ` data:image/png;base64 `
301
+ - [ Object] Type
302
+ - [ Boolean] ** ` animated ` ** Is animated, default value is ` false `
303
+ - [ Array] ** ` extensions ` ** possible of image extension
304
+ - [ Image] ** ` image ` ** image with base64 format, it should start with ` data:image/png;base64 `
296
305
- Mainly format from ` png ` , ` jpg ` , ` webp ` , or ` base64 `
297
- - Animated Image
306
+ - Animated/GIF Image
298
307
- [ Object] Type
299
308
- [ Integer] ** ` width ` ** Width of the gif
300
309
- [ Integer] ** ` height ` ** Height of the gif
301
310
- [ Boolean] ** ` animated ` ** Is animated, default value is ` true `
311
+ - [ Array] ** ` extensions ` ** possible of image extension
302
312
- [ Array] ** ` images ` ** Array images of the gif
303
313
- [ Image] ** ` img ` ** image generate from canvas
304
314
- [ Integer] ** ` delay ` ** Delay for the each frame
305
315
- [ Integer] ** ` loopCount ` ** Loop for the gif, if it is ` 0 ` , mean infinity loop
316
+ - [ Integer] ** ` totalFrames ` ** Total frames in this gif image
306
317
- Mainly format from ` gif ` or multiple local png image
307
318
308
319
## Align Format
@@ -328,4 +339,5 @@ const image = await this.Canvas.bridge(img, 0)
328
339
14 . Canvas Send Image
329
340
15 . Canvas Set Gif Option
330
341
16 . Store Canvas Info
331
- 16 . Canvas Generate Graph
342
+ 17 . Canvas Generate Graph
343
+ 18 . About Canvas Mod
0 commit comments