Skip to content

Commit 6ea2510

Browse files
committed
Update 3.1.0
1. Added overlap for gif which is filling missing pixel from previous image 2. Supported nodejs v16 3. Removed dependencies file 4. Fixed most of the gif image issues 5. Fixed draw text auto wrap problem 6. Supported discord.js v13 reply features 7. Improved speed for blur image up from 30 seconds++ to around 1 second 8. Improved extensions for update old raw data for latest default value
1 parent f39800f commit 6ea2510

25 files changed

+397
-1684
lines changed

README.md

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
- [Installation](#installation)
1919
- [NPM Module Required](#npm-module-required)
20+
- [Canvas Dependencies Required](#canvas-dependencies-required)
2021
- [Documentation](#documentation)
2122
- [Image Format](#image-format)
2223
- [Align Format](#align-format)
@@ -25,6 +26,7 @@
2526
## Installation Guide
2627
- Download the release from [here](https://github.com/LeonZ2019/dbm-canvas/releases)
2728
- Extract files and folder to your bot's directory actions folder
29+
- Get all canvas dependencies from [here](#canvas-dependencies-required)
2830

2931
## NPM Module Required
3032
- Basic Section
@@ -44,6 +46,11 @@
4446
- [x] chalk
4547
- [x] node-fetch
4648

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+
4754
## Documentation
4855
### Basic Image Manipulate
4956
* [Create Image](#create-image)
@@ -59,7 +66,7 @@
5966
* [Generate Graph](#generate-graph)
6067
### Others
6168
* [Image Buffer](#image-buffer)
62-
* [GIF Image Buffer](#gif-image-buffer)
69+
* [Save Image Local](#save-image-local)
6370
* [Discord Attachment](#discord-attachment)
6471
* [Image Bridge](#image-bridge)
6572

@@ -72,8 +79,9 @@ Image type support png, jpg, gif webp(still image) and of course base64 image, i
7279
- [Object] **`options`**
7380
- [Integer] **`delay`** Delay for gif if image is animated
7481
- [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
7583
```
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) => {
7785
})
7886
7987
// or with async/await:
@@ -244,22 +252,21 @@ this.Canvas.generateChart('bar', 800, 400, 'Score', ['Team Red', 'Team Blue', 'T
244252
```js
245253
DBM.Actions.Canvas.toBuffer(img) => [Buffer]
246254
```
247-
Convert still image to buffer
255+
Convert gif/still image to buffer
248256
- [Image] **`img`** image generate from canvas
249257
```js
250258
const buffer = DBM.Actions.Canvas.toBuffer(img)
251-
require('fs').writeFileSync('resources\image.png', buffer)
252259
```
253260

254-
## GIF Image Buffer
261+
## Save Image Local
255262
```js
256-
DBM.Actions.Canvas.GifToBuffer(img) => [Buffer]
263+
DBM.Actions.Canvas.Export(img, destination)
257264
```
258-
Convert gif or animated image to buffer
265+
Save gif/still image to local directly
259266
- [Image] **`img`** image generate from canvas
267+
- [String] **`destination`** local path for image
260268
```js
261-
const buffer = DBM.Actions.Canvas.GifToBuffer(img)
262-
require('fs').writeFileSync('resources\image.gif', buffer)
269+
const buffer = DBM.Actions.Canvas.Export(img, 'resources\\export.png')
263270
```
264271

265272
## Discord Attachment
@@ -291,18 +298,22 @@ const image = await this.Canvas.bridge(img, 0)
291298

292299
## Image Format
293300
- 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`
296305
- Mainly format from `png`, `jpg`, `webp`, or `base64`
297-
- Animated Image
306+
- Animated/GIF Image
298307
- [Object] Type
299308
- [Integer] **`width`** Width of the gif
300309
- [Integer] **`height`** Height of the gif
301310
- [Boolean] **`animated`** Is animated, default value is `true`
311+
- [Array] **`extensions`** possible of image extension
302312
- [Array] **`images`** Array images of the gif
303313
- [Image] **`img`** image generate from canvas
304314
- [Integer] **`delay`** Delay for the each frame
305315
- [Integer] **`loopCount`** Loop for the gif, if it is `0`, mean infinity loop
316+
- [Integer] **`totalFrames`** Total frames in this gif image
306317
- Mainly format from `gif` or multiple local png image
307318

308319
## Align Format
@@ -328,4 +339,5 @@ const image = await this.Canvas.bridge(img, 0)
328339
14. Canvas Send Image
329340
15. Canvas Set Gif Option
330341
16. Store Canvas Info
331-
16. Canvas Generate Graph
342+
17. Canvas Generate Graph
343+
18. About Canvas Mod

actions/canvas_create_background_MOD.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ module.exports = {
8686
},
8787

8888
action (cache) {
89-
const data = cache.actions[cache.index]
89+
const data = this.Canvas.updateValue(cache.actions[cache.index])
9090
const Canvas = require('canvas')
9191
const width = parseInt(this.evalMessage(data.width, cache))
9292
const height = parseInt(this.evalMessage(data.height, cache))

0 commit comments

Comments
 (0)