📑 Added docs and examples.
This commit is contained in:
125
README.md
125
README.md
@@ -1,3 +1,126 @@
|
|||||||
|
<a href="https://nodei.co/npm/discord-image-generation/"><img src="https://nodei.co/npm/discord-image-generation.png?downloads=true&downloadRank=true&stars=true"></a>
|
||||||
|
|
||||||
|
<a href="https://discord.gg/qvzwqaM"><img src="https://discord.com/api/guilds/661897530459684865/widget.png" alt="Discord server"/></a>
|
||||||
|
|
||||||
# discord-image-generation
|
# discord-image-generation
|
||||||
|
|
||||||
> discord-image-generation is a powerfull module that allow you to generate awesome images.
|
A powerfull module that allow you to generate awesome images.
|
||||||
|
|
||||||
|
# Bugs and glitches
|
||||||
|
|
||||||
|
Feel free to report all bugs and glitches by creating an issue in the <a href="https://github.com/Mr-KayJayDee/discord-image-generation/issues">issue section.</a>
|
||||||
|
|
||||||
|
A correct and understandable issue contains :
|
||||||
|
- Steps to reproduce
|
||||||
|
- Code that summonned the error
|
||||||
|
- The complete error
|
||||||
|
|
||||||
|
You can also join me on my <a href="https://discord.gg/qvzwqaM">discord server.</a>
|
||||||
|
|
||||||
|
# Download
|
||||||
|
|
||||||
|
You can download it from <a href="https://www.npmjs.com/package/discord-image-generation">npmjs</a>.
|
||||||
|
|
||||||
|
```cli
|
||||||
|
npm i discord-image-generation
|
||||||
|
```
|
||||||
|
|
||||||
|
# Configuration
|
||||||
|
|
||||||
|
The first step is to import the module in your code.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const DIG = require("discord-image-generation");
|
||||||
|
```
|
||||||
|
|
||||||
|
# Available images
|
||||||
|
|
||||||
|
- .blur(`<Avatar>`, `<Level(Number)>`);
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
- .facepalm(`<Avatar>`);
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
- .gay(`<Avatar>`);
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
- .rip(`<Avatar>`);
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
- .trash(`<Avatar>`);
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
- .circle(`<Avatar>`);
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
- .greyscale(`<Avatar>`);
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
- .kiss(`<Avatar>`, `<Avatar2>`);
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
- .sepia(`<Avatar>`);
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
- .mms(`<Avatar>`);
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
- .spank(`<Avatar>`, `<Avatar2>`);
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
- .color(`<Color>`);
|
||||||
|
|
||||||
|
> An hex color is needed, like "#FF0000"
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
- .triggered(`<Avatar>`);
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
- .hitler(`<Avatar>`);
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
- .batslap(`<Avatar>`, `<Avatar2>`);
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
- .bed(`<Avatar>`, `<Avatar2>`);
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
- .invert(`<Avatar>`);
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
- .wanted(`<Avatar>`);
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
- .beautiful(`<Avatar>`);
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
- .jail(`<Avatar>`);
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
- .affect(`<Avatar>`);
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
- .delete(`<Avatar>`);
|
||||||
|
|
||||||
|

|
||||||
|
@@ -41,25 +41,31 @@ class DIG {
|
|||||||
if (!image) throw new Error("You must provide an image as a first argument.");
|
if (!image) throw new Error("You must provide an image as a first argument.");
|
||||||
let bg = await Canvas.loadImage(__dirname +"/assets/gay.png");
|
let bg = await Canvas.loadImage(__dirname +"/assets/gay.png");
|
||||||
let img = await Canvas.loadImage(image);
|
let img = await Canvas.loadImage(image);
|
||||||
const canvas = Canvas.createCanvas(400, 400);
|
const canvas = Canvas.createCanvas(480, 480);
|
||||||
const ctx = canvas.getContext("2d");
|
const ctx = canvas.getContext("2d");
|
||||||
ctx.drawImage(img, 0, 0, 400, 400);
|
ctx.drawImage(img, 0, 0, 480, 480);
|
||||||
ctx.drawImage(bg, 0, 0, 400, 400);
|
ctx.drawImage(bg, 0, 0, 480, 480);
|
||||||
return canvas.toBuffer();
|
return canvas.toBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
static async kiss(image1, image2) {
|
static async kiss(image1, image2) {
|
||||||
if (!image1) throw new Error("You must provide an image as a first argument.");
|
if (!image1) throw new Error("You must provide an image as a first argument.");
|
||||||
if (!image2) throw new Error("You must provide an image as a second argument.");
|
if (!image2) throw new Error("You must provide an image as a second argument.");
|
||||||
const canvas = Canvas.createCanvas(768, 574);
|
let base = await jimp.read(__dirname+"/assets/kiss.png");
|
||||||
const ctx = canvas.getContext("2d");
|
image1 = await jimp.read(image1);
|
||||||
const background = await Canvas.loadImage(__dirname +"/assets/kiss.png");
|
image2 = await jimp.read(image2);
|
||||||
ctx.drawImage(background, 0, 0, canvas.width, canvas.height);
|
image1.circle();
|
||||||
const avatar = await Canvas.loadImage(image1);
|
image2.circle();
|
||||||
const avatar1 = await Canvas.loadImage(image2);
|
base.resize(768, 574);
|
||||||
ctx.drawImage(avatar1, 370, 25, 200, 200);
|
image1.resize(200, 200);
|
||||||
ctx.drawImage(avatar, 150, 25, 200, 200);
|
image2.resize(200, 200);
|
||||||
return canvas.toBuffer();
|
base.composite(image1, 150, 25);
|
||||||
|
base.composite(image2, 350, 25);
|
||||||
|
let raw;
|
||||||
|
base.getBuffer("image/png", (err, buffer) => {
|
||||||
|
raw = buffer;
|
||||||
|
});
|
||||||
|
return raw;
|
||||||
}
|
}
|
||||||
|
|
||||||
static async rip(image) {
|
static async rip(image) {
|
||||||
@@ -79,6 +85,8 @@ class DIG {
|
|||||||
let bg = await jimp.read(__dirname +"/assets/spank.png");
|
let bg = await jimp.read(__dirname +"/assets/spank.png");
|
||||||
image1 = await jimp.read(image1);
|
image1 = await jimp.read(image1);
|
||||||
image2 = await jimp.read(image2);
|
image2 = await jimp.read(image2);
|
||||||
|
image1.circle();
|
||||||
|
image2.circle();
|
||||||
bg.resize(500, 500);
|
bg.resize(500, 500);
|
||||||
image1.resize(140, 140);
|
image1.resize(140, 140);
|
||||||
image2.resize(120, 120);
|
image2.resize(120, 120);
|
||||||
@@ -127,6 +135,7 @@ class DIG {
|
|||||||
static async blur(image, level = 5) {
|
static async blur(image, level = 5) {
|
||||||
if (!image) throw new Error("You must provide an image as a first argument.");
|
if (!image) throw new Error("You must provide an image as a first argument.");
|
||||||
image = await jimp.read(image);
|
image = await jimp.read(image);
|
||||||
|
image.resize(480, 480)
|
||||||
image.blur(isNaN(level) ? 5 : parseInt(level));
|
image.blur(isNaN(level) ? 5 : parseInt(level));
|
||||||
let raw;
|
let raw;
|
||||||
image.getBuffer("image/png", (err, buffer) => {
|
image.getBuffer("image/png", (err, buffer) => {
|
||||||
@@ -138,6 +147,7 @@ class DIG {
|
|||||||
static async greyscale(image) {
|
static async greyscale(image) {
|
||||||
if (!image) throw new Error("You must provide an image as a first argument.");
|
if (!image) throw new Error("You must provide an image as a first argument.");
|
||||||
image = await jimp.read(image);
|
image = await jimp.read(image);
|
||||||
|
image.resize(480, 480)
|
||||||
image.greyscale();
|
image.greyscale();
|
||||||
let raw;
|
let raw;
|
||||||
image.getBuffer("image/png", (err, buffer) => {
|
image.getBuffer("image/png", (err, buffer) => {
|
||||||
@@ -149,6 +159,7 @@ class DIG {
|
|||||||
static async sepia(image) {
|
static async sepia(image) {
|
||||||
if (!image) throw new Error("You must provide an image as a first argument.");
|
if (!image) throw new Error("You must provide an image as a first argument.");
|
||||||
image = await jimp.read(image);
|
image = await jimp.read(image);
|
||||||
|
image.resize(480, 480)
|
||||||
image.sepia();
|
image.sepia();
|
||||||
let raw;
|
let raw;
|
||||||
image.getBuffer("image/png", (err, buffer) => {
|
image.getBuffer("image/png", (err, buffer) => {
|
||||||
@@ -160,6 +171,7 @@ class DIG {
|
|||||||
static async invert(image) {
|
static async invert(image) {
|
||||||
if (!image) throw new Error("You must provide an image as a first argument.");
|
if (!image) throw new Error("You must provide an image as a first argument.");
|
||||||
image = await jimp.read(image);
|
image = await jimp.read(image);
|
||||||
|
image.resize(480, 480)
|
||||||
image.invert();
|
image.invert();
|
||||||
let raw;
|
let raw;
|
||||||
image.getBuffer("image/png", (err, buffer) => {
|
image.getBuffer("image/png", (err, buffer) => {
|
||||||
@@ -222,6 +234,8 @@ class DIG {
|
|||||||
let bg = await jimp.read(__dirname +"/assets/bed.png");
|
let bg = await jimp.read(__dirname +"/assets/bed.png");
|
||||||
image1 = await jimp.read(image1);
|
image1 = await jimp.read(image1);
|
||||||
image2 = await jimp.read(image2);
|
image2 = await jimp.read(image2);
|
||||||
|
image1.circle();
|
||||||
|
image2.circle();
|
||||||
image1.resize(100, 100);
|
image1.resize(100, 100);
|
||||||
image2.resize(70, 70);
|
image2.resize(70, 70);
|
||||||
let image3 = image1.clone().resize(70, 70);
|
let image3 = image1.clone().resize(70, 70);
|
||||||
@@ -249,7 +263,7 @@ class DIG {
|
|||||||
return raw;
|
return raw;
|
||||||
}
|
}
|
||||||
|
|
||||||
static async trigger(image) {
|
static async triggered(image) {
|
||||||
if (!image) throw new Error("You must provide an image as a first argument.");
|
if (!image) throw new Error("You must provide an image as a first argument.");
|
||||||
const base = await Canvas.loadImage(__dirname +"/assets/triggered.png");
|
const base = await Canvas.loadImage(__dirname +"/assets/triggered.png");
|
||||||
const img = await Canvas.loadImage(image);
|
const img = await Canvas.loadImage(image);
|
||||||
@@ -276,6 +290,7 @@ class DIG {
|
|||||||
static async circle(image) {
|
static async circle(image) {
|
||||||
if (!image) throw new Error("You must provide an image as a first argument.");
|
if (!image) throw new Error("You must provide an image as a first argument.");
|
||||||
image = await jimp.read(image);
|
image = await jimp.read(image);
|
||||||
|
image.resize(480, 480);
|
||||||
image.circle();
|
image.circle();
|
||||||
let raw;
|
let raw;
|
||||||
image.getBuffer("image/png", (err, buffer) => {
|
image.getBuffer("image/png", (err, buffer) => {
|
||||||
|
Reference in New Issue
Block a user