Compare commits
10 Commits
053845ca75
...
master
Author | SHA1 | Date | |
---|---|---|---|
![]() |
dc7ddd4b13 | ||
![]() |
440558b15c | ||
![]() |
81022d878d | ||
![]() |
aff9a2d44c | ||
![]() |
ee59000301 | ||
![]() |
144b4d4e60 | ||
![]() |
9c811372e2 | ||
![]() |
ffece633f3 | ||
a156dcedda | |||
![]() |
8f96e3e620 |
2
.github/workflows/npm-publish.yaml
vendored
2
.github/workflows/npm-publish.yaml
vendored
@@ -3,7 +3,7 @@ name: Node.js package
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- main
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|
||||||
|
183
README.md
183
README.md
@@ -6,16 +6,22 @@ A powerfull module that allow you to generate awesome images.
|
|||||||
|
|
||||||
# Bugs and glitches
|
# 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>
|
Feel free to report all bugs and glitches by creating an issue in the <a href="https://git.mrkayjaydee.xyz/Mr-KayJayDee/discord-image-generation/issues">issue section.</a>
|
||||||
|
|
||||||
A correct and understandable issue contains :
|
A correct and understandable issue contains :
|
||||||
- Steps to reproduce
|
- Steps to reproduce
|
||||||
- Code that summonned the error
|
- Code that summonned the error
|
||||||
- The complete error
|
- The complete error
|
||||||
|
|
||||||
You can also join me on my <a href="https://discord.gg/Uqd2sQP">discord server.</a>
|
Please join [this](https://discord.gg/5ZSGFYtnqw) community server to follow all my projects or if you need help.
|
||||||
|
|
||||||
<a href="https://discord.gg/Uqd2sQP"><img src="https://discord.com/api/guilds/527836578912010251/widget.png" alt="Amandine support server"/></a>
|
# Links:
|
||||||
|
|
||||||
|
### Support Server Community
|
||||||
|
<a href="https://discord.gg/5ZSGFYtnqw"><img src="https://discord.com/api/guilds/833309512412299276/widget.png" alt="Coding support server"/></a>
|
||||||
|
|
||||||
|
### Xinko Discord Bot Support Server
|
||||||
|
<a href="https://discord.gg/Uqd2sQP"><img src="https://discord.com/api/guilds/527836578912010251/widget.png" alt="Xinko support server"/></a>
|
||||||
|
|
||||||
# Download
|
# Download
|
||||||
|
|
||||||
@@ -35,36 +41,124 @@ const DIG = require("discord-image-generation");
|
|||||||
|
|
||||||
Then you have to request your image and send it as an attachement.
|
Then you have to request your image and send it as an attachement.
|
||||||
|
|
||||||
|
## Discord.js v13
|
||||||
```js
|
```js
|
||||||
// Import the discord.js library.
|
// Import the discord.js library.
|
||||||
const Discord = require("discord.js")
|
const Discord = require("discord.js");
|
||||||
// Create a new discord.js client.
|
// Create a new discord.js client.
|
||||||
const bot = new Discord.Client()
|
const bot = new Discord.Client();
|
||||||
|
|
||||||
const DIG = require("discord-image-generation");
|
const DIG = require("discord-image-generation");
|
||||||
> You can also destructure to avoid repeating DIG.
|
|
||||||
|
|
||||||
// Listen to the ready event
|
// Listen to the ready event
|
||||||
bot.on("ready", () => {
|
bot.on("ready", () => {
|
||||||
console.log("ok");
|
console.log("Bot is online");
|
||||||
})
|
});
|
||||||
|
|
||||||
// Listen to the message event
|
// Listen to the message event
|
||||||
bot.on("message", async (message) => {
|
bot.on("messageCreate", async (message) => {
|
||||||
|
// Send the image in a simple message
|
||||||
if (message.content === "*delete") {
|
if (message.content === "*delete") {
|
||||||
// Get the avatarUrl of the user
|
// Get the avatarUrl of the user
|
||||||
let avatar = message.author.displayAvatarURL({ dynamic: false, format: 'png' });
|
let avatar = message.author.displayAvatarURL({
|
||||||
|
dynamic: false,
|
||||||
|
format: 'png'
|
||||||
|
});
|
||||||
// Make the image
|
// Make the image
|
||||||
let img = await new DIG.Delete().getImage(avatar)
|
let img = await new DIG.Delete().getImage(avatar);
|
||||||
// Add the image as an attachement
|
// Add the image as an attachement
|
||||||
let attach = new Discord.MessageAttachment(img, "delete.png");;
|
let attach = new Discord.MessageAttachment(img, "delete.png");
|
||||||
message.channel.send(attach)
|
message.channel.send({
|
||||||
|
files: [attach]
|
||||||
|
});
|
||||||
}
|
}
|
||||||
})
|
// Send the message with the image attached to an embed
|
||||||
|
if (message.content === "*blur") {
|
||||||
|
// Get the avatarUrl of the user
|
||||||
|
let avatar = message.author.displayAvatarURL({
|
||||||
|
dynamic: false,
|
||||||
|
format: 'png'
|
||||||
|
});
|
||||||
|
// Make the image
|
||||||
|
let img = await new DIG.Blur().getImage(avatar);
|
||||||
|
// Add the image as an attachement
|
||||||
|
let embed = new Discord.MessageEmbed()
|
||||||
|
.setTitle("Blur")
|
||||||
|
.setImage("attachment://delete.png");
|
||||||
|
let attach = new Discord.MessageAttachment(img, "blur.png");
|
||||||
|
message.channel.send({
|
||||||
|
embeds: [embed],
|
||||||
|
files: [attach]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Log in to the bot
|
// Log in to the bot
|
||||||
bot.login("super_secret_token")
|
bot.login("super_secret_token");
|
||||||
````
|
```
|
||||||
|
|
||||||
|
## Discord.js v14
|
||||||
|
```js
|
||||||
|
// Import the required elements from the discord.js library.
|
||||||
|
const { Client, GatewayIntentBits, AttachmentBuilder, EmbedBuilder } = require("discord.js");
|
||||||
|
// Create a new discord.js client.
|
||||||
|
const bot = new Client({
|
||||||
|
intents: [
|
||||||
|
GatewayIntentBits.Guilds,
|
||||||
|
GatewayIntentBits.GuildMembers,
|
||||||
|
GatewayIntentBits.GuildMessages,
|
||||||
|
GatewayIntentBits.MessageContent,
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
const DIG = require("discord-image-generation");
|
||||||
|
|
||||||
|
// Listen to the ready event
|
||||||
|
bot.on("ready", () => {
|
||||||
|
console.log("Bot is online");
|
||||||
|
});
|
||||||
|
|
||||||
|
// Listen to the message event
|
||||||
|
bot.on("messageCreate", async (message) => {
|
||||||
|
// Send the image in a simple message
|
||||||
|
if (message.content === "*delete") {
|
||||||
|
// Get the avatarUrl of the user
|
||||||
|
let avatar = message.author.displayAvatarURL({
|
||||||
|
forceStatic: true,
|
||||||
|
extension: 'png'
|
||||||
|
});
|
||||||
|
// Make the image
|
||||||
|
let img = await new DIG.Delete().getImage(avatar);
|
||||||
|
// Add the image as an attachement
|
||||||
|
let attach = new AttachmentBuilder(img).setName("delete.png");
|
||||||
|
message.channel.send({
|
||||||
|
files: [attach]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// Send the message with the image attached to an embed
|
||||||
|
if (message.content === "*blur") {
|
||||||
|
// Get the avatarUrl of the user
|
||||||
|
let avatar = message.author.displayAvatarURL({
|
||||||
|
forceStatic: true,
|
||||||
|
extension: 'png'
|
||||||
|
});
|
||||||
|
// Make the image
|
||||||
|
let img = await new DIG.Blur().getImage(avatar);
|
||||||
|
// Add the image as an attachement
|
||||||
|
let embed = new EmbedBuilder()
|
||||||
|
.setTitle("Blur")
|
||||||
|
.setImage("attachment://blur.png");
|
||||||
|
let attach = new AttachmentBuilder(img).setName("blur.png");
|
||||||
|
message.channel.send({
|
||||||
|
embeds: [embed],
|
||||||
|
files: [attach]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Log in to the bot
|
||||||
|
bot.login("super_secret_token");
|
||||||
|
```
|
||||||
|
|
||||||
# Available images
|
# Available images
|
||||||
|
|
||||||
@@ -94,7 +188,7 @@ bot.login("super_secret_token")
|
|||||||
|
|
||||||
## Gifs
|
## Gifs
|
||||||
|
|
||||||
- ``new DIG.Blink().getImage(`<Avatar>`, `<Avatar2>`.....);``
|
- ``new DIG.Blink().getImage(delay (in ms), `<Avatar>`, `<Avatar2>`.....);``
|
||||||
|
|
||||||
> You can add as many images as you want
|
> You can add as many images as you want
|
||||||
|
|
||||||
@@ -131,10 +225,19 @@ bot.login("super_secret_token")
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
- ``new DIG.Clown().getImage(`<Avatar>`);``
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
- ``new DIG.ConfusedStonk().getImage(`<Avatar>`);``
|
- ``new DIG.ConfusedStonk().getImage(`<Avatar>`);``
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
|
||||||
|
- ``new DIG.Deepfry().getImage(`<Avatar>`);``
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
- ``new DIG.Delete().getImage(`<Avatar>`);``
|
- ``new DIG.Delete().getImage(`<Avatar>`);``
|
||||||
|
|
||||||

|

|
||||||
@@ -155,6 +258,10 @@ bot.login("super_secret_token")
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
- ``new DIG.Heartbreaking().getImage(`<Avatar>`);``
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
- ``new DIG.Hitler().getImage(`<Avatar>`);``
|
- ``new DIG.Hitler().getImage(`<Avatar>`);``
|
||||||
|
|
||||||

|

|
||||||
@@ -177,6 +284,10 @@ bot.login("super_secret_token")
|
|||||||
|
|
||||||
> Limited to 300char
|
> Limited to 300char
|
||||||
|
|
||||||
|
- ``new DIG.Mikkelsen().getImage(`<Avatar>`);``
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
(Thanks to sιмση ℓεcℓεяε#5765)
|
(Thanks to sιмση ℓεcℓεяε#5765)
|
||||||
- ``new DIG.Mms().getImage(`<Avatar>`);``
|
- ``new DIG.Mms().getImage(`<Avatar>`);``
|
||||||
|
|
||||||
@@ -198,6 +309,10 @@ bot.login("super_secret_token")
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
- ``new DIG.Snyder().getImage(`<Avatar>`);``
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
- ``new DIG.Spank().getImage(`<Avatar>`, `<Avatar2>`);``
|
- ``new DIG.Spank().getImage(`<Avatar>`, `<Avatar2>`);``
|
||||||
|
|
||||||

|

|
||||||
@@ -237,8 +352,39 @@ bot.login("super_secret_token")
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
- ``new DIG.Denoise().getImage(`<Avatar>`, `<Level>`);``
|
||||||
|
|
||||||
|
> Level should be a number
|
||||||
|
|
||||||
|
- ``new DIG.Mirror().getImage(`<Avatar>`, `true`, `false`);``
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## v1.4.24
|
||||||
|
- Re added typings
|
||||||
|
|
||||||
|
## v1.4.23
|
||||||
|
- Fixed import issue
|
||||||
|
- Added Denoise()
|
||||||
|
- Added Mirror()
|
||||||
|
|
||||||
|
## v1.4.22
|
||||||
|
- Fixed some bugs
|
||||||
|
|
||||||
|
## v1.4.21
|
||||||
|
- Added discord.js V14 usage example
|
||||||
|
- Removed discord.js V12 usage example
|
||||||
|
|
||||||
|
## v1.4.20
|
||||||
|
- Some fixes
|
||||||
|
- Added Clown() (thanks to Retrojection#1937)
|
||||||
|
- Added Deepfry() (thanks to Retrojection#1937)
|
||||||
|
- Added Heartbreaking() (thanks to Retrojection#1937)
|
||||||
|
- Added Mikkelsen() (thanks to Retrojection#1937)
|
||||||
|
- Added Snyder() (thanks to Retrojection#1937)
|
||||||
|
|
||||||
## v1.4.7
|
## v1.4.7
|
||||||
- Improved Blink() generation, now supports adding an insane amount of images ^^
|
- Improved Blink() generation, now supports adding an insane amount of images ^^
|
||||||
|
|
||||||
@@ -318,3 +464,6 @@ bot.login("super_secret_token")
|
|||||||
- There is now a random price diplayed
|
- There is now a random price diplayed
|
||||||
- You can now configure a currency
|
- You can now configure a currency
|
||||||
- Added .thomas()
|
- Added .thomas()
|
||||||
|
|
||||||
|
|
||||||
|
Thanks to Alex15#0010 for the big help ! ❤
|
28
package.json
28
package.json
@@ -1,22 +1,25 @@
|
|||||||
{
|
{
|
||||||
"name": "discord-image-generation",
|
"name": "discord-image-generation",
|
||||||
"version": "1.4.7",
|
"version": "1.4.25",
|
||||||
"description": "discord-image-generation is a powerfull module that allow you to generate awesome images.",
|
"description": "discord-image-generation is a powerful module that allow you to generate awesome images.",
|
||||||
"main": "src/index.js",
|
"main": "src/index.js",
|
||||||
"types": "typings/index.d.ts",
|
"types": "typings/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "node src/index.js"
|
"test": "node tests/test.js"
|
||||||
|
},
|
||||||
|
"author": {
|
||||||
|
"name": "Mr¤KayJayDee",
|
||||||
|
"email": "killian.dalcin@gmail.com"
|
||||||
},
|
},
|
||||||
"author": "Mr¤KayJayDee <killian.dalcin@gmail.com> (https://github.com/Mr-KayJayDee)",
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/Mr-KayJayDee/discord-image-generation.git"
|
"url": "https://git.mrkayjaydee.xyz/Mr-KayJayDee/discord-image-generation"
|
||||||
},
|
},
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/Mr-KayJayDee/discord-image-generation/issues"
|
"url": "https://git.mrkayjaydee.xyz/Mr-KayJayDee/discord-image-generation/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/Mr-KayJayDee/discord-image-generation#readme",
|
"homepage": "https://git.mrkayjaydee.xyz/Mr-KayJayDee/discord-image-generation/src/branch/main/README.md",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"discord",
|
"discord",
|
||||||
"images",
|
"images",
|
||||||
@@ -30,8 +33,15 @@
|
|||||||
"drawing"
|
"drawing"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"canvas": "^2.6.1",
|
"canvas": "^2.10.1",
|
||||||
|
"discord-image-generation": "file:",
|
||||||
|
"discord.js": "^14.7.1",
|
||||||
"gifencoder": "^2.0.1",
|
"gifencoder": "^2.0.1",
|
||||||
"jimp": "^0.16.1"
|
"jimp": "^0.16.0"
|
||||||
|
},
|
||||||
|
"overrides": {
|
||||||
|
"jimp": {
|
||||||
|
"jpeg-js": "^0.4.4"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
BIN
src/assets/clown.png
Normal file
BIN
src/assets/clown.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 979 KiB |
BIN
src/assets/heartbreaking.png
Normal file
BIN
src/assets/heartbreaking.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 229 KiB |
BIN
src/assets/mikkelsen.png
Normal file
BIN
src/assets/mikkelsen.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 MiB |
BIN
src/assets/snyder.png
Normal file
BIN
src/assets/snyder.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 855 KiB |
@@ -1,19 +1,12 @@
|
|||||||
const jimp = require(`jimp`);
|
const jimp = require(`jimp`);
|
||||||
|
const { validateURL } = require(`../functions`);
|
||||||
module.exports = class Blur {
|
module.exports = class Blur {
|
||||||
/**
|
|
||||||
* Blur
|
|
||||||
* @param {image} image
|
|
||||||
* @param {level} level
|
|
||||||
*/
|
|
||||||
async getImage(image, level) {
|
async getImage(image, level) {
|
||||||
if (!image) throw new Error(`You must provide an image as a first argument.`);
|
if (!image) return console.error(`You must provide an image as a first argument.`);
|
||||||
|
let isValid = await validateURL(image);
|
||||||
|
if (!isValid) return console.error(`You must provide a valid image URL or buffer.`);
|
||||||
image = await jimp.read(image);
|
image = await jimp.read(image);
|
||||||
image.blur(isNaN(level) ? 5 : parseInt(level));
|
image.blur(isNaN(level) ? 5 : parseInt(level));
|
||||||
let raw;
|
return await image.getBufferAsync(`image/png`);
|
||||||
image.getBuffer(`image/png`, (err, buffer) => {
|
|
||||||
raw = buffer;
|
|
||||||
});
|
|
||||||
return raw;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
@@ -1,12 +1,11 @@
|
|||||||
const Canvas = require(`canvas`);
|
const Canvas = require(`canvas`);
|
||||||
|
const { validateURL } = require(`../functions`);
|
||||||
|
|
||||||
module.exports = class Gay {
|
module.exports = class Gay {
|
||||||
/**
|
|
||||||
* Gay
|
|
||||||
* @param {image} image
|
|
||||||
*/
|
|
||||||
async getImage(image) {
|
async getImage(image) {
|
||||||
if (!image) throw new Error(`You must provide an image as a first argument.`);
|
if (!image) return console.error(`You must provide an image as a first argument.`);
|
||||||
|
let isValid = await validateURL(image);
|
||||||
|
if (!isValid) return console.error(`You must provide a valid image URL or buffer.`);
|
||||||
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(480, 480);
|
const canvas = Canvas.createCanvas(480, 480);
|
||||||
|
@@ -1,18 +1,12 @@
|
|||||||
const jimp = require(`jimp`);
|
const jimp = require(`jimp`);
|
||||||
|
const { validateURL } = require(`../functions`);
|
||||||
module.exports = class Geryscale {
|
module.exports = class Geryscale {
|
||||||
/**
|
|
||||||
* Greyscale
|
|
||||||
* @param {image} image
|
|
||||||
*/
|
|
||||||
async getImage(image) {
|
async getImage(image) {
|
||||||
if (!image) throw new Error(`You must provide an image as a first argument.`);
|
if (!image) return console.error(`You must provide an image as a first argument.`);
|
||||||
|
let isValid = await validateURL(image);
|
||||||
|
if (!isValid) return console.error(`You must provide a valid image URL or buffer.`);
|
||||||
image = await jimp.read(image);
|
image = await jimp.read(image);
|
||||||
image.greyscale();
|
image.greyscale();
|
||||||
let raw;
|
return await image.getBufferAsync(`image/png`);
|
||||||
image.getBuffer(`image/png`, (err, buffer) => {
|
|
||||||
raw = buffer;
|
|
||||||
});
|
|
||||||
return raw;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
@@ -1,18 +1,12 @@
|
|||||||
const jimp = require(`jimp`);
|
const jimp = require(`jimp`);
|
||||||
|
const { validateURL } = require(`../functions`);
|
||||||
module.exports = class Invert {
|
module.exports = class Invert {
|
||||||
/**
|
|
||||||
* Invert
|
|
||||||
* @param {image} image
|
|
||||||
*/
|
|
||||||
async getImage(image) {
|
async getImage(image) {
|
||||||
if (!image) throw new Error(`You must provide an image as a first argument.`);
|
if (!image) return console.error(`You must provide an image as a first argument.`);
|
||||||
|
let isValid = await validateURL(image);
|
||||||
|
if (!isValid) return console.error(`You must provide a valid image URL or buffer.`);
|
||||||
image = await jimp.read(image);
|
image = await jimp.read(image);
|
||||||
image.invert();
|
image.invert();
|
||||||
let raw;
|
return await image.getBufferAsync(`image/png`);
|
||||||
image.getBuffer(`image/png`, (err, buffer) => {
|
|
||||||
raw = buffer;
|
|
||||||
});
|
|
||||||
return raw;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
@@ -1,18 +1,12 @@
|
|||||||
const jimp = require(`jimp`);
|
const jimp = require(`jimp`);
|
||||||
|
const { validateURL } = require(`../functions`);
|
||||||
module.exports = class Sepia {
|
module.exports = class Sepia {
|
||||||
/**
|
|
||||||
* Sepia
|
|
||||||
* @param {image} image
|
|
||||||
*/
|
|
||||||
async getImage(image) {
|
async getImage(image) {
|
||||||
if (!image) throw new Error(`You must provide an image as a first argument.`);
|
if (!image) return console.error(`You must provide an image as a first argument.`);
|
||||||
|
let isValid = await validateURL(image);
|
||||||
|
if (!isValid) return console.error(`You must provide a valid image URL or buffer.`);
|
||||||
image = await jimp.read(image);
|
image = await jimp.read(image);
|
||||||
image.sepia();
|
image.sepia();
|
||||||
let raw;
|
return await image.getBufferAsync(`image/png`);
|
||||||
image.getBuffer(`image/png`, (err, buffer) => {
|
|
||||||
raw = buffer;
|
|
||||||
});
|
|
||||||
return raw;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
@@ -1,3 +1,5 @@
|
|||||||
|
const https = require(`https`);
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
/**
|
/**
|
||||||
* Crate a responsive on the text
|
* Crate a responsive on the text
|
||||||
@@ -47,5 +49,38 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
return resolve(lines);
|
return resolve(lines);
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
async validateURL(url) {
|
||||||
|
if (!url) return null;
|
||||||
|
if (Buffer.isBuffer(url)) {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
// if url is not https
|
||||||
|
if (!url.startsWith(`https`)) {
|
||||||
|
return console.error(`The url must be https`);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
https.get(url, (response) => {
|
||||||
|
if (response.statusCode !== 200) {
|
||||||
|
return console.error(`Invalid status code ${response.statusCode}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const type = response.headers['content-type'];
|
||||||
|
if (!type.startsWith('image/')) {
|
||||||
|
return console.error(`Invalid content type ${type}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const chunks = [];
|
||||||
|
response.on('data', (chunk) => chunks.push(chunk));
|
||||||
|
response.on('end', () => resolve(Buffer.concat(chunks)));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
return console.error(error);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
@@ -1,15 +1,20 @@
|
|||||||
const Canvas = require(`canvas`);
|
const Canvas = require(`canvas`);
|
||||||
const GIFEncoder = require(`gifencoder`);
|
const GIFEncoder = require(`gifencoder`);
|
||||||
|
const { validateURL } = require(`../functions`);
|
||||||
module.exports = class Blink {
|
module.exports = class Blink {
|
||||||
|
async getImage(delay, ...images) {
|
||||||
|
if (!images || images.length < 2) return console.error(`You must provide at least two images.`);
|
||||||
|
|
||||||
async getImage( ...images) {
|
if (isNaN(delay)) return console.error(`You must provide a valid delay.`);
|
||||||
if (!images || images.length < 2) throw new Error(`You must provide at least two images.`);
|
for (const image of images) {
|
||||||
|
let isValid = await validateURL(image);
|
||||||
|
if (!isValid) return console.error(`You must provide a valid image URL or buffer.`);
|
||||||
|
}
|
||||||
|
|
||||||
const GIF = new GIFEncoder(480, 480);
|
const GIF = new GIFEncoder(480, 480);
|
||||||
GIF.start();
|
GIF.start();
|
||||||
GIF.setRepeat(0);
|
GIF.setRepeat(0);
|
||||||
GIF.setDelay(1000);
|
GIF.setDelay(delay);
|
||||||
GIF.setTransparent();
|
GIF.setTransparent();
|
||||||
|
|
||||||
const canvas = Canvas.createCanvas(480, 480);
|
const canvas = Canvas.createCanvas(480, 480);
|
||||||
|
@@ -1,16 +1,13 @@
|
|||||||
const Canvas = require(`canvas`);
|
const Canvas = require(`canvas`);
|
||||||
|
|
||||||
const GIFEncoder = require(`gifencoder`);
|
const GIFEncoder = require(`gifencoder`);
|
||||||
|
const { validateURL } = require(`../functions`);
|
||||||
module.exports = class Triggered {
|
module.exports = class Triggered {
|
||||||
/**
|
|
||||||
* Triggered
|
|
||||||
* @param {image} image
|
|
||||||
* @param {number} timeout
|
|
||||||
*/
|
|
||||||
async getImage(image, timeout = 15) {
|
async getImage(image, timeout = 15) {
|
||||||
if (!image) throw new Error(`You must provide an image as a first argument.`);
|
if (!image) return console.error(`You must provide an image as a first argument.`);
|
||||||
if (isNaN(timeout)) throw new Error(`The timeout argument must be a number.`);
|
let isValid = await validateURL(image);
|
||||||
|
if (!isValid) return console.error(`You must provide a valid image URL or buffer.`);
|
||||||
|
if (isNaN(timeout)) return console.error(`The timeout argument must be a number.`);
|
||||||
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);
|
||||||
const GIF = new GIFEncoder(256, 310);
|
const GIF = new GIFEncoder(256, 310);
|
||||||
|
@@ -1,18 +1,14 @@
|
|||||||
const Canvas = require(`canvas`);
|
const Jimp = require('jimp');
|
||||||
|
const { validateURL } = require(`../functions`);
|
||||||
module.exports = class Ad {
|
module.exports = class Ad {
|
||||||
/**
|
|
||||||
* Ad
|
|
||||||
* @param {image} image1
|
|
||||||
*/
|
|
||||||
async getImage(image1) {
|
async getImage(image1) {
|
||||||
if (!image1) throw new Error(`You must provide an image as an argument`);
|
if (!image1) return console.error(`You must provide an image as an argument`);
|
||||||
const canvas = Canvas.createCanvas(550, 474);
|
let isValid = await validateURL(image1);
|
||||||
const ctx = canvas.getContext(`2d`);
|
if (!isValid) return console.error(`You must provide a valid image URL or buffer.`);
|
||||||
image1 = await Canvas.loadImage(image1);
|
const image1Buffer = await Jimp.read(image1);
|
||||||
const background = await Canvas.loadImage(`${__dirname}/../../assets/ad.png`);
|
image1Buffer.resize(230, 230);
|
||||||
ctx.drawImage(image1, 150, 75, 230, 230);
|
const background = await Jimp.read(`${__dirname}/../../assets/ad.png`);
|
||||||
ctx.drawImage(background, 0, 0, 550, 474);
|
background.composite(image1Buffer, 150, 75);
|
||||||
return canvas.toBuffer();
|
return background.getBufferAsync(Jimp.MIME_PNG);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -1,20 +1,14 @@
|
|||||||
const jimp = require(`jimp`);
|
const jimp = require(`jimp`);
|
||||||
|
const { validateURL } = require(`../functions`);
|
||||||
module.exports = class Affect {
|
module.exports = class Affect {
|
||||||
/**
|
|
||||||
* Affect
|
|
||||||
* @param {image} image
|
|
||||||
*/
|
|
||||||
async getImage(image) {
|
async getImage(image) {
|
||||||
if (!image) throw new Error(`You must provide an image as a first argument.`);
|
if (!image) return console.error(`You must provide an image as a first argument.`);
|
||||||
|
let isValid = await validateURL(image);
|
||||||
|
if (!isValid) return console.error(`You must provide a valid image URL or buffer.`);
|
||||||
let base = await jimp.read(`${__dirname}/../../assets/affect.png`);
|
let base = await jimp.read(`${__dirname}/../../assets/affect.png`);
|
||||||
let img = await jimp.read(image);
|
let img = await jimp.read(image);
|
||||||
img.resize(200, 157);
|
img.resize(200, 157);
|
||||||
base.composite(img, 180, 383);
|
base.composite(img, 180, 383);
|
||||||
let raw;
|
return await base.getBufferAsync(`image/png`);
|
||||||
base.getBuffer(`image/png`, (err, buffer) => {
|
|
||||||
raw = buffer;
|
|
||||||
});
|
|
||||||
return raw;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
@@ -1,14 +1,13 @@
|
|||||||
const jimp = require(`jimp`);
|
const jimp = require(`jimp`);
|
||||||
|
const { validateURL } = require(`../functions`);
|
||||||
module.exports = class Batslap {
|
module.exports = class Batslap {
|
||||||
/**
|
|
||||||
* Batslap
|
|
||||||
* @param {image} image1
|
|
||||||
* @param {image} image2
|
|
||||||
*/
|
|
||||||
async getImage(image1, image2) {
|
async getImage(image1, image2) {
|
||||||
if (!image1) throw new Error(`You must provide an image as a first argument.`);
|
if (!image1) return console.error(`You must provide an image as a first argument.`);
|
||||||
if (!image2) throw new Error(`You must provide an image as a second argument.`);
|
let isValid1 = await validateURL(image1);
|
||||||
|
if (!isValid1) return console.error(`You must provide a valid image URL or buffer.`);
|
||||||
|
if (!image2) return console.error(`You must provide an image as a second argument.`);
|
||||||
|
let isValid2 = await validateURL(image1);
|
||||||
|
if (!isValid2) return console.error(`You must provide a valid image URL or buffer.`);
|
||||||
let base = await jimp.read(`${__dirname}/../../assets/batslap.png`);
|
let base = await jimp.read(`${__dirname}/../../assets/batslap.png`);
|
||||||
image1 = await jimp.read(image1);
|
image1 = await jimp.read(image1);
|
||||||
image2 = await jimp.read(image2);
|
image2 = await jimp.read(image2);
|
||||||
@@ -19,10 +18,6 @@ module.exports = class Batslap {
|
|||||||
image2.resize(200, 200);
|
image2.resize(200, 200);
|
||||||
base.composite(image2, 580, 260);
|
base.composite(image2, 580, 260);
|
||||||
base.composite(image1, 350, 70);
|
base.composite(image1, 350, 70);
|
||||||
let raw;
|
return await base.getBufferAsync(`image/png`);
|
||||||
base.getBuffer(`image/png`, (err, buffer) => {
|
|
||||||
raw = buffer;
|
|
||||||
});
|
|
||||||
return raw;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
@@ -1,22 +1,16 @@
|
|||||||
const jimp = require(`jimp`);
|
const jimp = require(`jimp`);
|
||||||
|
const { validateURL } = require(`../functions`);
|
||||||
module.exports = class Beautiful {
|
module.exports = class Beautiful {
|
||||||
/**
|
|
||||||
* Beautiful
|
|
||||||
* @param {image} image
|
|
||||||
*/
|
|
||||||
async getImage(image) {
|
async getImage(image) {
|
||||||
if (!image) throw new Error(`You must provide an image as a first argument.`);
|
if (!image) return console.error(`You must provide an image as a first argument.`);
|
||||||
|
let isValid = await validateURL(image);
|
||||||
|
if (!isValid) return console.error(`You must provide a valid image URL or buffer.`);
|
||||||
let base = await jimp.read(`${__dirname}/../../assets/beautiful.png`);
|
let base = await jimp.read(`${__dirname}/../../assets/beautiful.png`);
|
||||||
base.resize(376, 400);
|
base.resize(376, 400);
|
||||||
let img = await jimp.read(image);
|
let img = await jimp.read(image);
|
||||||
img.resize(84, 95);
|
img.resize(84, 95);
|
||||||
base.composite(img, 258, 28);
|
base.composite(img, 258, 28);
|
||||||
base.composite(img, 258, 229);
|
base.composite(img, 258, 229);
|
||||||
let raw;
|
return await base.getBufferAsync(`image/png`);
|
||||||
base.getBuffer(`image/png`, (err, buffer) => {
|
|
||||||
raw = buffer;
|
|
||||||
});
|
|
||||||
return raw;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
@@ -1,14 +1,13 @@
|
|||||||
const jimp = require(`jimp`);
|
const jimp = require(`jimp`);
|
||||||
|
const { validateURL } = require(`../functions`);
|
||||||
module.exports = class Bed {
|
module.exports = class Bed {
|
||||||
/**
|
|
||||||
* Bed
|
|
||||||
* @param {image} image1
|
|
||||||
* @param {image} image2
|
|
||||||
*/
|
|
||||||
async getImage(image1, image2) {
|
async getImage(image1, image2) {
|
||||||
if (!image1) throw new Error(`You must provide an image as a first argument.`);
|
if (!image1) return console.error(`You must provide an image as a first argument.`);
|
||||||
if (!image2) throw new Error(`You must provide an image as a second argument.`);
|
let isValid1 = await validateURL(image1);
|
||||||
|
if (!isValid1) return console.error(`You must provide a valid image URL or buffer.`);
|
||||||
|
if (!image2) return console.error(`You must provide an image as a second argument.`);
|
||||||
|
let isValid2 = await validateURL(image2);
|
||||||
|
if (!isValid2) return console.error(`You must provide a valid image URL or buffer.`);
|
||||||
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);
|
||||||
@@ -21,10 +20,6 @@ module.exports = class Bed {
|
|||||||
bg.composite(image1, 25, 300);
|
bg.composite(image1, 25, 300);
|
||||||
bg.composite(image3, 53, 450);
|
bg.composite(image3, 53, 450);
|
||||||
bg.composite(image2, 53, 575);
|
bg.composite(image2, 53, 575);
|
||||||
let raw;
|
return await bg.getBufferAsync(`image/png`);
|
||||||
bg.getBuffer(`image/png`, (err, buffer) => {
|
|
||||||
raw = buffer;
|
|
||||||
});
|
|
||||||
return raw;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
@@ -1,20 +1,16 @@
|
|||||||
const { createCanvas, loadImage } = require(`canvas`);
|
const Jimp = require('jimp');
|
||||||
|
const { validateURL } = require(`../functions`);
|
||||||
module.exports = class Bobross {
|
module.exports = class Bobross {
|
||||||
/**
|
|
||||||
* Bobross
|
|
||||||
* @param {image} image1
|
|
||||||
*/
|
|
||||||
async getImage(image1) {
|
async getImage(image1) {
|
||||||
if (!image1) throw new Error(`You must provide an image as an argument`);
|
if (!image1) return console.error(`You must provide an image as an argument`);
|
||||||
const base = await loadImage(`${__dirname}/../../assets/bobross.png`);
|
let isValid = await validateURL(image1);
|
||||||
const canvas = createCanvas(base.width, base.height);
|
if (!isValid) return console.error(`You must provide a valid image URL or buffer.`);
|
||||||
const ctx = canvas.getContext(`2d`);
|
const base = await Jimp.read(`${__dirname}/../../assets/bobross.png`);
|
||||||
image1 = await loadImage(image1);
|
const image1Buffer = await Jimp.read(image1);
|
||||||
ctx.fillStyle = `white`;
|
image1Buffer.resize(440, 440);
|
||||||
ctx.fillRect(0, 0, base.width, base.height);
|
const compositeImage = new Jimp(base.getWidth(), base.getHeight(), 0xFFFFFFFF);
|
||||||
ctx.drawImage(image1, 15, 20, 440, 440);
|
compositeImage.composite(image1Buffer, 15, 20);
|
||||||
ctx.drawImage(base, 0, 0);
|
compositeImage.composite(base, 0, 0);
|
||||||
return canvas.toBuffer();
|
return compositeImage.getBufferAsync(Jimp.MIME_PNG);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
28
src/module/montage/clown.js
Normal file
28
src/module/montage/clown.js
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
const Canvas = require(`canvas`);
|
||||||
|
const { validateURL } = require(`../functions`);
|
||||||
|
|
||||||
|
module.exports = class Clown {
|
||||||
|
async getImage(image) {
|
||||||
|
|
||||||
|
function drawImage(ctx, image, x, y, w, h, degrees) {
|
||||||
|
ctx.save();
|
||||||
|
ctx.translate(x + w / 2, y + h / 2);
|
||||||
|
ctx.rotate(degrees * Math.PI / 180.0);
|
||||||
|
ctx.translate(-x - w / 2, -y - h / 2);
|
||||||
|
ctx.drawImage(image, x, y, w, h);
|
||||||
|
ctx.restore();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!image) throw new Error(`You must provide an image as an argument`);
|
||||||
|
let isValid = await validateURL(image);
|
||||||
|
if (!isValid) return console.error(`You must provide a valid image URL or buffer.`);
|
||||||
|
const canvas = Canvas.createCanvas(610, 343);
|
||||||
|
const ctx = canvas.getContext(`2d`);
|
||||||
|
image = await Canvas.loadImage(image);
|
||||||
|
const background = await Canvas.loadImage(`${__dirname}/../../assets/clown.png`);
|
||||||
|
ctx.fillRect(0, 0, 610, 343);
|
||||||
|
drawImage(ctx, image, 15, 55, 145, 130, -5);
|
||||||
|
ctx.drawImage(background, 0, 0, 610, 343);
|
||||||
|
return canvas.toBuffer();
|
||||||
|
}
|
||||||
|
}
|
@@ -1,18 +1,16 @@
|
|||||||
const Canvas = require(`canvas`);
|
const Jimp = require('jimp');
|
||||||
|
const { validateURL } = require(`../functions`);
|
||||||
module.exports = class ConfusedStonk {
|
module.exports = class ConfusedStonk {
|
||||||
/**
|
async getImage(image) {
|
||||||
* ConfusedStonk
|
if (!image) return console.error(`You must provide an image as an argument`);
|
||||||
* @param {image} image1
|
let isValid = await validateURL(image);
|
||||||
*/
|
if (!isValid) return console.error(`You must provide a valid image URL or buffer.`);
|
||||||
async getImage(image1) {
|
const image1 = await Jimp.read(image);
|
||||||
if (!image1) throw new Error(`You must provide an image as an argument`);
|
const background = await Jimp.read(`${__dirname}/../../assets/confusedStonk.png`);
|
||||||
const canvas = Canvas.createCanvas(1994, 1296);
|
image1.resize(400, 400);
|
||||||
const ctx = canvas.getContext(`2d`);
|
const compositeImage = new Jimp(background.getWidth(), background.getHeight(), 0xFFFFFFFF);
|
||||||
image1 = await Canvas.loadImage(image1);
|
compositeImage.composite(image1, 190, 70);
|
||||||
const background = await Canvas.loadImage(`${__dirname}/../../assets/confusedStonk.png`);
|
compositeImage.composite(background, 0, 0);
|
||||||
ctx.drawImage(image1, 190, 70, 400, 400);
|
return await compositeImage.getBufferAsync(Jimp.MIME_PNG);
|
||||||
ctx.drawImage(background, 0, 0, 1994, 1296);
|
|
||||||
return canvas.toBuffer();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
16
src/module/montage/deepfry.js
Normal file
16
src/module/montage/deepfry.js
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
const jimp = require(`jimp`);
|
||||||
|
const { validateURL } = require(`../functions`);
|
||||||
|
|
||||||
|
module.exports = class Deepfry {
|
||||||
|
async getImage(image) {
|
||||||
|
if (!image) throw new Error(`You must provide an image as a first argument.`);
|
||||||
|
let isValid = await validateURL(image);
|
||||||
|
if (!isValid) return console.error(`You must provide a valid image URL or buffer.`);
|
||||||
|
image = await jimp.read(image);
|
||||||
|
image.quality(2)
|
||||||
|
image.contrast(1);
|
||||||
|
image.pixelate(2);
|
||||||
|
image.posterize(10);
|
||||||
|
return await image.getBufferAsync(`image/png`);
|
||||||
|
}
|
||||||
|
};
|
@@ -1,20 +1,14 @@
|
|||||||
const jimp = require(`jimp`);
|
const jimp = require(`jimp`);
|
||||||
|
const { validateURL } = require(`../functions`);
|
||||||
module.exports = class Delete {
|
module.exports = class Delete {
|
||||||
/**
|
|
||||||
* Delete
|
|
||||||
* @param {image} image
|
|
||||||
*/
|
|
||||||
async getImage(image) {
|
async getImage(image) {
|
||||||
if (!image) throw new Error(`You must provide an image as a first argument.`);
|
if (!image) return console.error(`You must provide an image as a first argument.`);
|
||||||
let bg = await jimp.read(`${__dirname}/../../assets/delete.png`);
|
let isValid = await validateURL(image);
|
||||||
|
if (!isValid) return console.error(`You must provide a valid image URL or buffer.`);
|
||||||
|
const background = await jimp.read(`${__dirname}/../../assets/delete.png`);
|
||||||
image = await jimp.read(image);
|
image = await jimp.read(image);
|
||||||
image.resize(195, 195);
|
image.resize(195, 195);
|
||||||
bg.composite(image, 120, 135);
|
background.composite(image, 120, 135);
|
||||||
let raw;
|
return await background.getBufferAsync(`image/png`);
|
||||||
bg.getBuffer(`image/png`, (err, buffer) => {
|
|
||||||
raw = buffer;
|
|
||||||
});
|
|
||||||
return raw;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
@@ -1,18 +1,16 @@
|
|||||||
const Canvas = require(`canvas`);
|
const Jimp = require('jimp');
|
||||||
|
const { validateURL } = require(`../functions`);
|
||||||
module.exports = class DiscordBlack {
|
module.exports = class DiscordBlack {
|
||||||
/**
|
async getImage(image) {
|
||||||
* Bobross
|
if (!image) return console.error(`You must provide an image as an argument`);
|
||||||
* @param {image} image1
|
let isValid = await validateURL(image);
|
||||||
*/
|
if (!isValid) return console.error(`You must provide a valid image URL or buffer.`);
|
||||||
async getImage(image1) {
|
const background = await Jimp.read(`${__dirname}/../../assets/discordblack.png`);
|
||||||
if (!image1) throw new Error(`You must provide an image as an argument`);
|
const image1 = await Jimp.read(image);
|
||||||
const canvas = Canvas.createCanvas(610, 610);
|
image1.resize(background.getWidth(), background.getHeight());
|
||||||
const ctx = canvas.getContext(`2d`);
|
const compositeImage = new Jimp(background.getWidth(), background.getHeight(), 0xFFFFFFFF);
|
||||||
image1 = await Canvas.loadImage(image1);
|
compositeImage.composite(image1, 0, 0);
|
||||||
const background = await Canvas.loadImage(`${__dirname}/../../assets/discordblack.png`);
|
compositeImage.composite(background, 0, 0);
|
||||||
ctx.drawImage(image1, 0, 0, 610, 610);
|
return await compositeImage.getBufferAsync(Jimp.MIME_PNG);
|
||||||
ctx.drawImage(background, 0, 0, 610, 610);
|
|
||||||
return canvas.toBuffer();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -1,18 +1,16 @@
|
|||||||
const Canvas = require(`canvas`);
|
const Jimp = require('jimp');
|
||||||
|
const { validateURL } = require(`../functions`);
|
||||||
module.exports = class DiscordBlue {
|
module.exports = class DiscordBlue {
|
||||||
/**
|
async getImage(image) {
|
||||||
* Bobross
|
if (!image) return console.error(`You must provide an image as an argument`);
|
||||||
* @param {image} image1
|
let isValid = await validateURL(image);
|
||||||
*/
|
if (!isValid) return console.error(`You must provide a valid image URL or buffer.`);
|
||||||
async getImage(image1) {
|
const background = await Jimp.read(`${__dirname}/../../assets/discordblue.png`);
|
||||||
if (!image1) throw new Error(`You must provide an image as an argument`);
|
const image1 = await Jimp.read(image);
|
||||||
const canvas = Canvas.createCanvas(610, 610);
|
image1.resize(background.getWidth(), background.getHeight());
|
||||||
const ctx = canvas.getContext(`2d`);
|
const compositeImage = new Jimp(background.getWidth(), background.getHeight(), 0xFFFFFFFF);
|
||||||
image1 = await Canvas.loadImage(image1);
|
compositeImage.composite(image1, 0, 0);
|
||||||
const background = await Canvas.loadImage(`${__dirname}/../../assets/discordblue.png`);
|
compositeImage.composite(background, 0, 0);
|
||||||
ctx.drawImage(image1, 0, 0, 610, 610);
|
return await compositeImage.getBufferAsync(Jimp.MIME_PNG);
|
||||||
ctx.drawImage(background, 0, 0, 610, 610);
|
|
||||||
return canvas.toBuffer();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -1,14 +1,13 @@
|
|||||||
const jimp = require(`jimp`);
|
const jimp = require(`jimp`);
|
||||||
|
const { validateURL } = require(`../functions`);
|
||||||
module.exports = class DoubleStonk {
|
module.exports = class DoubleStonk {
|
||||||
/**
|
|
||||||
* DoubleStonk
|
|
||||||
* @param {image} image1
|
|
||||||
* @param {image} image2
|
|
||||||
*/
|
|
||||||
async getImage(image1, image2) {
|
async getImage(image1, image2) {
|
||||||
if (!image1) throw new Error(`You must provide an image as a first argument.`);
|
if (!image1) return console.error(`You must provide an image as a first argument.`);
|
||||||
if (!image2) throw new Error(`You must provide an image as a second argument.`);
|
let isValid1 = await validateURL(image1);
|
||||||
|
if (!isValid1) return console.error(`You must provide a valid image URL or buffer.`);
|
||||||
|
if (!image2) return console.error(`You must provide an image as a second argument.`);
|
||||||
|
let isValid2 = await validateURL(image2);
|
||||||
|
if (!isValid2) return console.error(`You must provide a valid image URL or buffer.`);
|
||||||
let base = await jimp.read(`${__dirname}/../../assets/doubleStonk.png`);
|
let base = await jimp.read(`${__dirname}/../../assets/doubleStonk.png`);
|
||||||
image1 = await jimp.read(image1);
|
image1 = await jimp.read(image1);
|
||||||
image2 = await jimp.read(image2);
|
image2 = await jimp.read(image2);
|
||||||
@@ -19,10 +18,6 @@ module.exports = class DoubleStonk {
|
|||||||
image2.resize(140, 140);
|
image2.resize(140, 140);
|
||||||
base.composite(image2, 60, 20);
|
base.composite(image2, 60, 20);
|
||||||
base.composite(image1, 0, 30);
|
base.composite(image1, 0, 30);
|
||||||
let raw;
|
return await base.getBufferAsync(`image/png`);
|
||||||
base.getBuffer(`image/png`, (err, buffer) => {
|
|
||||||
raw = buffer;
|
|
||||||
});
|
|
||||||
return raw;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
@@ -1,20 +1,16 @@
|
|||||||
const Canvas = require(`canvas`);
|
const Jimp = require('jimp');
|
||||||
|
const { validateURL } = require(`../functions`);
|
||||||
module.exports = class Facepalm {
|
module.exports = class Facepalm {
|
||||||
/**
|
|
||||||
* Facepalm
|
|
||||||
* @param {image} image
|
|
||||||
*/
|
|
||||||
async getImage(image) {
|
async getImage(image) {
|
||||||
if (!image) throw new Error(`You must provide an image as a first argument.`);
|
if (!image) return console.error(`You must provide an image as an argument.`);
|
||||||
let canvas = Canvas.createCanvas(632, 357);
|
let isValid = await validateURL(image);
|
||||||
let ctx = canvas.getContext(`2d`);
|
if (!isValid) return console.error(`You must provide a valid image URL or buffer.`);
|
||||||
ctx.fillStyle = `black`;
|
const layer = await Jimp.read(`${__dirname}/../../assets/facepalm.png`);
|
||||||
ctx.fillRect(0, 0, 632, 357);
|
const avatar = await Jimp.read(image);
|
||||||
let avatar = await Canvas.loadImage(image);
|
const compositeImage = new Jimp(layer.getWidth(), layer.getHeight(), 0xFFFFFFFF);
|
||||||
ctx.drawImage(avatar, 199, 112, 235, 235);
|
avatar.resize(235, 235);
|
||||||
let layer = await Canvas.loadImage(`${__dirname}/../../assets/facepalm.png`);
|
compositeImage.composite(avatar, 199, 112);
|
||||||
ctx.drawImage(layer, 0, 0, 632, 357);
|
compositeImage.composite(layer, 0, 0);
|
||||||
return canvas.toBuffer();
|
return await compositeImage.getBufferAsync(Jimp.MIME_PNG);
|
||||||
}
|
}
|
||||||
};
|
};
|
17
src/module/montage/heartbreaking.js
Normal file
17
src/module/montage/heartbreaking.js
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
const Canvas = require(`canvas`);
|
||||||
|
const { validateURL } = require(`../functions`);
|
||||||
|
|
||||||
|
module.exports = class Heartbreaking {
|
||||||
|
async getImage(image) {
|
||||||
|
if (!image) throw new Error(`You must provide an image as an argument`);
|
||||||
|
let isValid = await validateURL(image);
|
||||||
|
if (!isValid) return console.error(`You must provide a valid image URL or buffer.`);
|
||||||
|
const canvas = Canvas.createCanvas(610, 797);
|
||||||
|
const ctx = canvas.getContext(`2d`);
|
||||||
|
image = await Canvas.loadImage(image);
|
||||||
|
const background = await Canvas.loadImage(`${__dirname}/../../assets/heartbreaking.png`);
|
||||||
|
ctx.drawImage(image, 0, 150, 610, 610);
|
||||||
|
ctx.drawImage(background, 0, 0, 610, 797);
|
||||||
|
return canvas.toBuffer();
|
||||||
|
}
|
||||||
|
};
|
@@ -1,20 +1,14 @@
|
|||||||
const jimp = require(`jimp`);
|
const jimp = require(`jimp`);
|
||||||
|
const { validateURL } = require(`../functions`);
|
||||||
module.exports = class Hitler {
|
module.exports = class Hitler {
|
||||||
/**
|
|
||||||
* Hitler
|
|
||||||
* @param {image} image
|
|
||||||
*/
|
|
||||||
async getImage(image) {
|
async getImage(image) {
|
||||||
if (!image) throw new Error(`You must provide an image as a first argument.`);
|
if (!image) return console.error(`You must provide an image as a first argument.`);
|
||||||
|
let isValid = await validateURL(image);
|
||||||
|
if (!isValid) return console.error(`You must provide a valid image URL or buffer.`);
|
||||||
let bg = await jimp.read(`${__dirname}/../../assets/hitler.png`);
|
let bg = await jimp.read(`${__dirname}/../../assets/hitler.png`);
|
||||||
let img = await jimp.read(image);
|
let img = await jimp.read(image);
|
||||||
img.resize(140, 140);
|
img.resize(140, 140);
|
||||||
bg.composite(img, 46, 43);
|
bg.composite(img, 46, 43);
|
||||||
let raw;
|
return await bg.getBufferAsync(`image/png`);
|
||||||
bg.getBuffer(`image/png`, (err, buffer) => {
|
|
||||||
raw = buffer;
|
|
||||||
});
|
|
||||||
return raw;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
@@ -1,18 +1,17 @@
|
|||||||
const Canvas = require(`canvas`);
|
const Jimp = require('jimp');
|
||||||
|
const { validateURL } = require(`../functions`);
|
||||||
module.exports = class Jail {
|
module.exports = class Jail {
|
||||||
/**
|
|
||||||
* Jail
|
|
||||||
* @param {image} image
|
|
||||||
*/
|
|
||||||
async getImage(image) {
|
async getImage(image) {
|
||||||
if (!image) throw new Error(`You must provide an image as a first argument.`);
|
if (!image) return console.error(`You must provide an image as a first argument.`);
|
||||||
let bg = await Canvas.loadImage(`${__dirname}/../../assets/jail.png`);
|
let isValid = await validateURL(image);
|
||||||
let img = await Canvas.loadImage(image);
|
if (!isValid) return console.error(`You must provide a valid image URL or buffer.`);
|
||||||
const canvas = Canvas.createCanvas(400, 400);
|
let bg = await Jimp.read(`${__dirname}/../../assets/jail.png`);
|
||||||
const ctx = canvas.getContext(`2d`);
|
let img = await Jimp.read(image);
|
||||||
ctx.drawImage(img, 0, 0, 400, 400);
|
const compositeImage = new Jimp(400, 400, 0xFFFFFFFF);
|
||||||
ctx.drawImage(bg, 0, 0, 400, 400);
|
img.resize(400, 400);
|
||||||
return canvas.toBuffer();
|
bg.resize(400, 400);
|
||||||
|
compositeImage.composite(img, 0, 0);
|
||||||
|
compositeImage.composite(bg, 0, 0);
|
||||||
|
return await compositeImage.getBufferAsync(Jimp.MIME_PNG);
|
||||||
}
|
}
|
||||||
};
|
};
|
@@ -1,18 +1,17 @@
|
|||||||
const Canvas = require(`canvas`);
|
const Jimp = require('jimp');
|
||||||
|
const { validateURL } = require(`../functions`);
|
||||||
module.exports = class Mms {
|
module.exports = class Karaba {
|
||||||
/**
|
|
||||||
* MMS
|
|
||||||
* @param {image} image
|
|
||||||
*/
|
|
||||||
async getImage(image) {
|
async getImage(image) {
|
||||||
if (!image) throw new Error(`You must provide an image as an argument`);
|
if (!image) return console.error(`You must provide an image as an argument`);
|
||||||
let bg = await Canvas.loadImage(`${__dirname}/../../assets/karaba.png`);
|
let isValid = await validateURL(image);
|
||||||
let img = await Canvas.loadImage(image);
|
if (!isValid) return console.error(`You must provide a valid image URL or buffer.`);
|
||||||
const canvas = Canvas.createCanvas(bg.width, bg.height);
|
let bg = await Jimp.read(`${__dirname}/../../assets/karaba.png`);
|
||||||
const ctx = canvas.getContext(`2d`);
|
let img = await Jimp.read(image);
|
||||||
ctx.drawImage(img, 130, 44, 130, 130);
|
const compositeImage = new Jimp(bg.getWidth(), bg.getHeight(), 0xFFFFFFFF);
|
||||||
ctx.drawImage(bg, 0, 0, bg.width, bg.height);
|
img.resize(130, 130);
|
||||||
return canvas.toBuffer();
|
bg.resize(bg.getWidth(), bg.getHeight());
|
||||||
|
compositeImage.composite(img, 130, 44);
|
||||||
|
compositeImage.composite(bg, 0, 0);
|
||||||
|
return await compositeImage.getBufferAsync(Jimp.MIME_PNG);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -1,14 +1,13 @@
|
|||||||
const jimp = require(`jimp`);
|
const jimp = require(`jimp`);
|
||||||
|
const { validateURL } = require(`../functions`);
|
||||||
module.exports = class Kiss {
|
module.exports = class Kiss {
|
||||||
/**
|
|
||||||
* Kiss
|
|
||||||
* @param {image} image1
|
|
||||||
* @param {image} image2
|
|
||||||
*/
|
|
||||||
async getImage(image1, image2) {
|
async getImage(image1, image2) {
|
||||||
if (!image1) throw new Error(`You must provide an image as a first argument.`);
|
if (!image1) return console.error(`You must provide an image as a first argument.`);
|
||||||
if (!image2) throw new Error(`You must provide an image as a second argument.`);
|
let isValid1 = await validateURL(image1);
|
||||||
|
if (!isValid1) return console.error(`You must provide a valid image URL or buffer.`);
|
||||||
|
if (!image2) return console.error(`You must provide an image as a second argument.`);
|
||||||
|
let isValid2 = await validateURL(image2);
|
||||||
|
if (!isValid2) return console.error(`You must provide a valid image URL or buffer.`);
|
||||||
let base = await jimp.read(`${__dirname}/../../assets/kiss.png`);
|
let base = await jimp.read(`${__dirname}/../../assets/kiss.png`);
|
||||||
image1 = await jimp.read(image1);
|
image1 = await jimp.read(image1);
|
||||||
image2 = await jimp.read(image2);
|
image2 = await jimp.read(image2);
|
||||||
@@ -19,10 +18,6 @@ module.exports = class Kiss {
|
|||||||
image2.resize(200, 200);
|
image2.resize(200, 200);
|
||||||
base.composite(image1, 150, 25);
|
base.composite(image1, 150, 25);
|
||||||
base.composite(image2, 350, 25);
|
base.composite(image2, 350, 25);
|
||||||
let raw;
|
return await base.getBufferAsync(`image/png`);
|
||||||
base.getBuffer(`image/png`, (err, buffer) => {
|
|
||||||
raw = buffer;
|
|
||||||
});
|
|
||||||
return raw;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
@@ -5,10 +5,8 @@ const path = require(`path`);
|
|||||||
const { wrapText } = require(`../functions`);
|
const { wrapText } = require(`../functions`);
|
||||||
|
|
||||||
module.exports = class LisaPresentation {
|
module.exports = class LisaPresentation {
|
||||||
|
|
||||||
async getImage(text) {
|
async getImage(text) {
|
||||||
if (!text || text.length > 300) throw new Error(`You must provide a text of 300 characters or less.`);
|
if (!text || text.length > 300) return console.error(`You must provide a text of 300 characters or less.`);
|
||||||
|
|
||||||
const base = await loadImage(path.join(`${__dirname}/../../assets/lisa-presentation.png`));
|
const base = await loadImage(path.join(`${__dirname}/../../assets/lisa-presentation.png`));
|
||||||
const canvas = createCanvas(base.width, base.height);
|
const canvas = createCanvas(base.width, base.height);
|
||||||
const ctx = canvas.getContext(`2d`);
|
const ctx = canvas.getContext(`2d`);
|
||||||
@@ -27,8 +25,6 @@ module.exports = class LisaPresentation {
|
|||||||
const height = topMost + ((fontSize + 20) * i);
|
const height = topMost + ((fontSize + 20) * i);
|
||||||
ctx.fillText(lines[i], base.width / 2, height);
|
ctx.fillText(lines[i], base.width / 2, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
return canvas.toBuffer();
|
return canvas.toBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
17
src/module/montage/mikkelsen.js
Normal file
17
src/module/montage/mikkelsen.js
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
const Canvas = require(`canvas`);
|
||||||
|
const { validateURL } = require(`../functions`);
|
||||||
|
|
||||||
|
module.exports = class Mikkelsen {
|
||||||
|
async getImage(image) {
|
||||||
|
if (!image) throw new Error(`You must provide an image as an argument`);
|
||||||
|
let isValid = await validateURL(image);
|
||||||
|
if (!isValid) return console.error(`You must provide a valid image URL or buffer.`);
|
||||||
|
const canvas = Canvas.createCanvas(610, 955);
|
||||||
|
const ctx = canvas.getContext(`2d`);
|
||||||
|
image = await Canvas.loadImage(image);
|
||||||
|
const background = await Canvas.loadImage(`${__dirname}/../../assets/mikkelsen.png`);
|
||||||
|
ctx.drawImage(image, 20, 460, 580, 580);
|
||||||
|
ctx.drawImage(background, 0, 0, 610, 955);
|
||||||
|
return canvas.toBuffer();
|
||||||
|
}
|
||||||
|
};
|
@@ -1,18 +1,17 @@
|
|||||||
const Canvas = require(`canvas`);
|
const Jimp = require(`jimp`);
|
||||||
|
const { validateURL } = require(`../functions`);
|
||||||
module.exports = class Mms {
|
module.exports = class Mms {
|
||||||
/**
|
|
||||||
* MMS
|
|
||||||
* @param {image} image
|
|
||||||
*/
|
|
||||||
async getImage(image) {
|
async getImage(image) {
|
||||||
if (!image) throw new Error(`You must provide an image as a first argument.`);
|
if (!image) return console.error(`You must provide an image as a first argument.`);
|
||||||
let bg = await Canvas.loadImage(`${__dirname}/../../assets/mms.png`);
|
let isValid = await validateURL(image);
|
||||||
let img = await Canvas.loadImage(image);
|
if (!isValid) return console.error(`You must provide a valid image URL or buffer.`);
|
||||||
const canvas = Canvas.createCanvas(400, 400);
|
const bg = await Jimp.read(`${__dirname}/../../assets/mms.png`);
|
||||||
const ctx = canvas.getContext(`2d`);
|
const img = await Jimp.read(image);
|
||||||
ctx.drawImage(img, 60, 10, 270, 270);
|
const canvas = new Jimp(400, 400);
|
||||||
ctx.drawImage(bg, 0, 0, 400, 400);
|
bg.resize(400, 400);
|
||||||
return canvas.toBuffer();
|
img.resize(270, 270);
|
||||||
|
canvas.composite(img, 60, 10);
|
||||||
|
canvas.composite(bg, 0, 0);
|
||||||
|
return canvas.getBufferAsync(Jimp.MIME_PNG);
|
||||||
}
|
}
|
||||||
};
|
};
|
@@ -1,18 +1,17 @@
|
|||||||
const Canvas = require(`canvas`);
|
const Jimp = require(`jimp`);
|
||||||
|
const { validateURL } = require(`../functions`);
|
||||||
module.exports = class NotStonk {
|
module.exports = class NotStonk {
|
||||||
/**
|
async getImage(image) {
|
||||||
* NotStonk
|
if (!image) return console.error(`You must provide an image as an argument`);
|
||||||
* @param {image} image1
|
let isValid = await validateURL(image);
|
||||||
*/
|
if (!isValid) return console.error(`You must provide a valid image URL or buffer.`);
|
||||||
async getImage(image1) {
|
const canvas = new Jimp(960, 576);
|
||||||
if (!image1) throw new Error(`You must provide an image as an argument`);
|
const img1 = await Jimp.read(image);
|
||||||
const canvas = Canvas.createCanvas(960, 576);
|
const background = await Jimp.read(`${__dirname}/../../assets/notStonk.png`);
|
||||||
const ctx = canvas.getContext(`2d`);
|
img1.resize(190, 190);
|
||||||
image1 = await Canvas.loadImage(image1);
|
background.resize(960, 576);
|
||||||
const background = await Canvas.loadImage(`${__dirname}/../../assets/notStonk.png`);
|
canvas.composite(img1, 140, 5);
|
||||||
ctx.drawImage(image1, 140, 5, 190, 190);
|
canvas.composite(background, 0, 0);
|
||||||
ctx.drawImage(background, 0, 0, 960, 576);
|
return canvas.getBufferAsync(Jimp.MIME_PNG);
|
||||||
return canvas.toBuffer();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -2,24 +2,21 @@ const Canvas = require(`canvas`);
|
|||||||
const {
|
const {
|
||||||
applyText
|
applyText
|
||||||
} = require(`../functions`);
|
} = require(`../functions`);
|
||||||
|
const { validateURL } = require(`../functions`);
|
||||||
module.exports = class Podium {
|
module.exports = class Podium {
|
||||||
/**
|
|
||||||
* Podium
|
|
||||||
* @param {image} image1
|
|
||||||
* @param {image} image2
|
|
||||||
* @param {image} image3
|
|
||||||
* @param {string} name1
|
|
||||||
* @param {string} name2
|
|
||||||
* @param {string} name3
|
|
||||||
*/
|
|
||||||
async getImage(image1, image2, image3, name1, name2, name3) {
|
async getImage(image1, image2, image3, name1, name2, name3) {
|
||||||
if (!image1) throw new Error(`You must provide an image as a first argument.`);
|
if (!image1) return console.error(`You must provide an image as a first argument.`);
|
||||||
if (!image2) throw new Error(`You must provide an image as a second argument.`);
|
let isValid1 = await validateURL(image1);
|
||||||
if (!image3) throw new Error(`You must provide an image as a third argument.`);
|
if (!isValid1) return console.error(`You must provide a valid image URL or buffer.`);
|
||||||
if (!name1) throw new Error(`You must provide a text as a fourth argument.`);
|
if (!image2) return console.error(`You must provide an image as a second argument.`);
|
||||||
if (!name2) throw new Error(`You must provide a text as a fifth argument.`);
|
let isValid2 = await validateURL(image2);
|
||||||
if (!name3) throw new Error(`You must provide a text as a sixth argument.`);
|
if (!isValid2) return console.error(`You must provide a valid image URL or buffer.`);
|
||||||
|
if (!image3) return console.error(`You must provide an image as a third argument.`);
|
||||||
|
let isValid3 = await validateURL(image3);
|
||||||
|
if (!isValid3) return console.error(`You must provide a valid image URL or buffer.`);
|
||||||
|
if (!name1) return console.error(`You must provide a text as a fourth argument.`);
|
||||||
|
if (!name2) return console.error(`You must provide a text as a fifth argument.`);
|
||||||
|
if (!name3) return console.error(`You must provide a text as a sixth argument.`);
|
||||||
const canvas = Canvas.createCanvas(1173, 686);
|
const canvas = Canvas.createCanvas(1173, 686);
|
||||||
const ctx = canvas.getContext(`2d`);
|
const ctx = canvas.getContext(`2d`);
|
||||||
image1 = await Canvas.loadImage(image1);
|
image1 = await Canvas.loadImage(image1);
|
||||||
|
@@ -1,18 +1,16 @@
|
|||||||
const Canvas = require(`canvas`);
|
const Jimp = require(`jimp`);
|
||||||
|
const { validateURL } = require(`../functions`);
|
||||||
|
// BUG: Placement de l'image n'est pas correcte
|
||||||
module.exports = class Poutine {
|
module.exports = class Poutine {
|
||||||
/**
|
async getImage(image) {
|
||||||
* Ad
|
if (!image) return console.error(`You must provide an image as an argument`);
|
||||||
* @param {image} image1
|
let isValid = await validateURL(image);
|
||||||
*/
|
if (!isValid) return console.error(`You must provide a valid image URL or buffer.`);
|
||||||
async getImage(image1) {
|
const canvas = new Jimp(600, 539);
|
||||||
if (!image1) throw new Error(`You must provide an image as an argument`);
|
const img1 = await Jimp.read(image);
|
||||||
const canvas = Canvas.createCanvas(600, 539);
|
const background = await Jimp.read(`${__dirname}/../../assets/poutine.png`);
|
||||||
const ctx = canvas.getContext(`2d`);
|
canvas.composite(img1, 350, 20);
|
||||||
image1 = await Canvas.loadImage(image1);
|
canvas.composite(background, 0, 0);
|
||||||
const background = await Canvas.loadImage(`${__dirname}/../../assets/poutine.png`);
|
return canvas.getBufferAsync(Jimp.MIME_PNG);
|
||||||
ctx.drawImage(image1, 350, 20, 135, 135);
|
|
||||||
ctx.drawImage(background, 0, 0, 600, 539);
|
|
||||||
return canvas.toBuffer();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -1,13 +1,10 @@
|
|||||||
const Canvas = require(`canvas`);
|
const Canvas = require(`canvas`);
|
||||||
|
const { validateURL } = require(`../functions`);
|
||||||
module.exports = class Rip {
|
module.exports = class Rip {
|
||||||
/**
|
|
||||||
* Rip
|
|
||||||
* @param {image} image
|
|
||||||
*/
|
|
||||||
|
|
||||||
async getImage(image) {
|
async getImage(image) {
|
||||||
if (!image) throw new Error(`You must provide an image as a first argument.`);
|
if (!image) return console.error(`You must provide an image as a first argument.`);
|
||||||
|
let isValid = await validateURL(image);
|
||||||
|
if (!isValid) return console.error(`You must provide a valid image URL or buffer.`);
|
||||||
const canvas = Canvas.createCanvas(720, 405);
|
const canvas = Canvas.createCanvas(720, 405);
|
||||||
const ctx = canvas.getContext(`2d`);
|
const ctx = canvas.getContext(`2d`);
|
||||||
const background = await Canvas.loadImage(`${__dirname}/../../assets/rip.png`);
|
const background = await Canvas.loadImage(`${__dirname}/../../assets/rip.png`);
|
||||||
|
28
src/module/montage/snyder.js
Normal file
28
src/module/montage/snyder.js
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
const Canvas = require(`canvas`);
|
||||||
|
const { validateURL } = require(`../functions`);
|
||||||
|
|
||||||
|
module.exports = class Snyder {
|
||||||
|
async getImage(image) {
|
||||||
|
|
||||||
|
function drawImage(ctx, image, x, y, w, h, degrees) {
|
||||||
|
ctx.save();
|
||||||
|
ctx.translate(x + w / 2, y + h / 2);
|
||||||
|
ctx.rotate(degrees * Math.PI / 180.0);
|
||||||
|
ctx.translate(-x - w / 2, -y - h / 2);
|
||||||
|
ctx.drawImage(image, x, y, w, h);
|
||||||
|
ctx.restore();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!image) throw new Error(`You must provide an image as an argument`);
|
||||||
|
let isValid = await validateURL(image);
|
||||||
|
if (!isValid) return console.error(`You must provide a valid image URL or buffer.`);
|
||||||
|
const canvas = Canvas.createCanvas(610, 343);
|
||||||
|
const ctx = canvas.getContext(`2d`);
|
||||||
|
image = await Canvas.loadImage(image);
|
||||||
|
const background = await Canvas.loadImage(`${__dirname}/../../assets/snyder.png`);
|
||||||
|
ctx.fillRect(0, 0, 610, 343);
|
||||||
|
drawImage(ctx, image, 62, 70, 300, 300, -6);
|
||||||
|
ctx.drawImage(background, 0, 0, 610, 343);
|
||||||
|
return canvas.toBuffer();
|
||||||
|
}
|
||||||
|
};
|
@@ -1,14 +1,13 @@
|
|||||||
const jimp = require(`jimp`);
|
const jimp = require(`jimp`);
|
||||||
|
const { validateURL } = require(`../functions`);
|
||||||
module.exports = class Spank {
|
module.exports = class Spank {
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param {image} image1
|
|
||||||
* @param {image} image2
|
|
||||||
*/
|
|
||||||
async getImage(image1, image2) {
|
async getImage(image1, image2) {
|
||||||
if (!image1) throw new Error(`You must provide an image as a first argument.`);
|
if (!image1) return console.error(`You must provide an image as a first argument.`);
|
||||||
if (!image2) throw new Error(`You must provide an image as a second argument.`);
|
let isValid1 = await validateURL(image1);
|
||||||
|
if (!isValid1) return console.error(`You must provide a valid image URL or buffer.`);
|
||||||
|
if (!image2) return console.error(`You must provide an image as a second argument.`);
|
||||||
|
let isValid2 = await validateURL(image2);
|
||||||
|
if (!isValid2) return console.error(`You must provide a valid image URL or buffer.`);
|
||||||
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);
|
||||||
@@ -21,10 +20,6 @@ module.exports = class Spank {
|
|||||||
image2.resize(120, 120);
|
image2.resize(120, 120);
|
||||||
bg.composite(image2, 350, 220);
|
bg.composite(image2, 350, 220);
|
||||||
bg.composite(image1, 225, 5);
|
bg.composite(image1, 225, 5);
|
||||||
let raw;
|
return await bg.getBufferAsync(`image/png`);
|
||||||
bg.getBuffer(`image/png`, (err, buffer) => {
|
|
||||||
raw = buffer;
|
|
||||||
});
|
|
||||||
return raw;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
@@ -1,17 +1,15 @@
|
|||||||
const Canvas = require(`canvas`);
|
const Canvas = require(`canvas`);
|
||||||
|
const { validateURL } = require(`../functions`);
|
||||||
module.exports = class Stonk {
|
module.exports = class Stonk {
|
||||||
/**
|
async getImage(image) {
|
||||||
* Stonk
|
if (!image) return console.error(`You must provide an image as an argument`);
|
||||||
* @param {image} image1
|
let isValid = await validateURL(image);
|
||||||
*/
|
if (!isValid) return console.error(`You must provide a valid image URL or buffer.`);
|
||||||
async getImage(image1) {
|
|
||||||
if (!image1) throw new Error(`You must provide an image as an argument`);
|
|
||||||
const canvas = Canvas.createCanvas(900, 539);
|
const canvas = Canvas.createCanvas(900, 539);
|
||||||
const ctx = canvas.getContext(`2d`);
|
const ctx = canvas.getContext(`2d`);
|
||||||
image1 = await Canvas.loadImage(image1);
|
image = await Canvas.loadImage(image);
|
||||||
const background = await Canvas.loadImage(`${__dirname}/../../assets/stonk.png`);
|
const background = await Canvas.loadImage(`${__dirname}/../../assets/stonk.png`);
|
||||||
ctx.drawImage(image1, 70, 40, 240, 240);
|
ctx.drawImage(image, 70, 40, 240, 240);
|
||||||
ctx.drawImage(background, 0, 0, 900, 539);
|
ctx.drawImage(background, 0, 0, 900, 539);
|
||||||
return canvas.toBuffer();
|
return canvas.toBuffer();
|
||||||
}
|
}
|
||||||
|
@@ -1,12 +1,10 @@
|
|||||||
const Canvas = require(`canvas`);
|
const Canvas = require(`canvas`);
|
||||||
|
const { validateURL } = require(`../functions`);
|
||||||
module.exports = class Tatoo {
|
module.exports = class Tatoo {
|
||||||
/**
|
|
||||||
* Tatoo
|
|
||||||
* @param {image} image
|
|
||||||
*/
|
|
||||||
async getImage(image) {
|
async getImage(image) {
|
||||||
if (!image) throw new Error(`You must provide an image as a first argument.`);
|
if (!image) return console.error(`You must provide an image as a first argument.`);
|
||||||
|
let isValid = await validateURL(image);
|
||||||
|
if (!isValid) return console.error(`You must provide a valid image URL or buffer.`);
|
||||||
const canvas = Canvas.createCanvas(750, 1089);
|
const canvas = Canvas.createCanvas(750, 1089);
|
||||||
const ctx = canvas.getContext(`2d`);
|
const ctx = canvas.getContext(`2d`);
|
||||||
const avatar = await Canvas.loadImage(image);
|
const avatar = await Canvas.loadImage(image);
|
||||||
|
@@ -1,12 +1,10 @@
|
|||||||
const Canvas = require(`canvas`);
|
const Canvas = require(`canvas`);
|
||||||
|
const { validateURL } = require(`../functions`);
|
||||||
module.exports = class Thomas {
|
module.exports = class Thomas {
|
||||||
/**
|
|
||||||
* Thomas
|
|
||||||
* @param {image} image
|
|
||||||
*/
|
|
||||||
async getImage(image) {
|
async getImage(image) {
|
||||||
if (!image) throw new Error(`You must provide an image as a first argument.`);
|
if (!image) return console.error(`You must provide an image as a first argument.`);
|
||||||
|
let isValid = await validateURL(image);
|
||||||
|
if (!isValid) return console.error(`You must provide a valid image URL or buffer.`);
|
||||||
const canvas = Canvas.createCanvas(841, 1058);
|
const canvas = Canvas.createCanvas(841, 1058);
|
||||||
const ctx = canvas.getContext(`2d`);
|
const ctx = canvas.getContext(`2d`);
|
||||||
const avatar = await Canvas.loadImage(image);
|
const avatar = await Canvas.loadImage(image);
|
||||||
|
@@ -1,21 +1,15 @@
|
|||||||
const jimp = require(`jimp`);
|
const jimp = require(`jimp`);
|
||||||
|
const { validateURL } = require(`../functions`);
|
||||||
module.exports = class Trash {
|
module.exports = class Trash {
|
||||||
/**
|
|
||||||
* Trash
|
|
||||||
* @param {image} image
|
|
||||||
*/
|
|
||||||
async getImage(image) {
|
async getImage(image) {
|
||||||
if (!image) throw new Error(`You must provide an image as a first argument.`);
|
if (!image) return console.error(`You must provide an image as a first argument.`);
|
||||||
|
let isValid = await validateURL(image);
|
||||||
|
if (!isValid) return console.error(`You must provide a valid image URL or buffer.`);
|
||||||
let bg = await jimp.read(`${__dirname}/../../assets/trash.png`);
|
let bg = await jimp.read(`${__dirname}/../../assets/trash.png`);
|
||||||
image = await jimp.read(image);
|
image = await jimp.read(image);
|
||||||
image.resize(309, 309);
|
image.resize(309, 309);
|
||||||
image.blur(5);
|
image.blur(5);
|
||||||
bg.composite(image, 309, 0);
|
bg.composite(image, 309, 0);
|
||||||
let raw;
|
return await bg.getBufferAsync(`image/png`);
|
||||||
bg.getBuffer(`image/png`, (err, buffer) => {
|
|
||||||
raw = buffer;
|
|
||||||
});
|
|
||||||
return raw;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
@@ -2,16 +2,14 @@ const Canvas = require(`canvas`);
|
|||||||
const {
|
const {
|
||||||
applyText
|
applyText
|
||||||
} = require(`../functions`);
|
} = require(`../functions`);
|
||||||
|
const { validateURL } = require(`../functions`);
|
||||||
module.exports = class Wanted {
|
module.exports = class Wanted {
|
||||||
/**
|
|
||||||
* Wanted
|
|
||||||
* @param {image} image
|
|
||||||
*/
|
|
||||||
async getImage(image, currency = `$`) {
|
async getImage(image, currency = `$`) {
|
||||||
if (!image) throw new Error(`You must provide an image as a first argument.`);
|
if (!image) return console.error(`You must provide an image as a first argument.`);
|
||||||
if (typeof currency != `string`) throw new Error(`You must provide a string for the currency.`);
|
let isValid = await validateURL(image);
|
||||||
if (currency.length > 1) throw new Error(`You must provide only one character for the currency.`);
|
if (!isValid) return console.error(`You must provide a valid image URL or buffer.`);
|
||||||
|
if (typeof currency != `string`) return console.error(`You must provide a string for the currency.`);
|
||||||
|
if (currency.length > 1) return console.error(`You must provide only one character for the currency.`);
|
||||||
var price = Math.floor(Math.random() * 188708) + 329889;
|
var price = Math.floor(Math.random() * 188708) + 329889;
|
||||||
const canvas = Canvas.createCanvas(257, 383);
|
const canvas = Canvas.createCanvas(257, 383);
|
||||||
const ctx = canvas.getContext(`2d`);
|
const ctx = canvas.getContext(`2d`);
|
||||||
|
@@ -1,19 +1,13 @@
|
|||||||
const jimp = require(`jimp`);
|
const jimp = require(`jimp`);
|
||||||
|
const { validateURL } = require(`../functions`);
|
||||||
module.exports = class Circle {
|
module.exports = class Circle {
|
||||||
/**
|
|
||||||
* Circle
|
|
||||||
* @param {image} image
|
|
||||||
*/
|
|
||||||
async getImage(image) {
|
async getImage(image) {
|
||||||
if (!image) throw new Error(`You must provide an image as a first argument.`);
|
if (!image) return console.error(`You must provide an image as a first argument.`);
|
||||||
|
let isValid = await validateURL(image);
|
||||||
|
if (!isValid) return console.error(`You must provide a valid image URL or buffer.`);
|
||||||
image = await jimp.read(image);
|
image = await jimp.read(image);
|
||||||
image.resize(480, 480);
|
image.resize(480, 480);
|
||||||
image.circle();
|
image.circle();
|
||||||
let raw;
|
return await image.getBufferAsync(`image/png`);
|
||||||
image.getBuffer(`image/png`, (err, buffer) => {
|
|
||||||
raw = buffer;
|
|
||||||
});
|
|
||||||
return raw;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
@@ -1,10 +1,6 @@
|
|||||||
const Canvas = require(`canvas`);
|
const Canvas = require(`canvas`);
|
||||||
|
|
||||||
module.exports = class Color {
|
module.exports = class Color {
|
||||||
/**
|
|
||||||
* Color
|
|
||||||
* @param {string} color
|
|
||||||
*/
|
|
||||||
async getImage(color = `#FFFFFF`) {
|
async getImage(color = `#FFFFFF`) {
|
||||||
const canvas = Canvas.createCanvas(2048, 2048);
|
const canvas = Canvas.createCanvas(2048, 2048);
|
||||||
const ctx = canvas.getContext(`2d`);
|
const ctx = canvas.getContext(`2d`);
|
||||||
|
16
src/module/utils/denoise.js
Normal file
16
src/module/utils/denoise.js
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
const jimp = require(`jimp`);
|
||||||
|
const { validateURL } = require(`../functions`);
|
||||||
|
module.exports = class Denoise {
|
||||||
|
async getImage(image, level = 1) {
|
||||||
|
if (!image) return console.error(`You must provide an image as a first argument.`);
|
||||||
|
let isValid = await validateURL(image);
|
||||||
|
if (!isValid) return console.error(`You must provide a valid image URL or buffer.`);
|
||||||
|
if (isNaN(level)) level = 1;
|
||||||
|
if (level > 10) level = 10;
|
||||||
|
if (level < 1) level = 1;
|
||||||
|
image = await jimp.read(image);
|
||||||
|
// apply gaussBlur
|
||||||
|
image.gaussian(level);
|
||||||
|
return await image.getBufferAsync(`image/png`);
|
||||||
|
}
|
||||||
|
};
|
12
src/module/utils/mirror.js
Normal file
12
src/module/utils/mirror.js
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
const jimp = require(`jimp`);
|
||||||
|
const { validateURL } = require(`../functions`);
|
||||||
|
module.exports = class Mirror {
|
||||||
|
async getImage(image, horizontal = true, vertical = false) {
|
||||||
|
if (!image) return console.error(`You must provide an image as a first argument.`);
|
||||||
|
let isValid = await validateURL(image);
|
||||||
|
if (!isValid) return console.error(`You must provide a valid image URL or buffer.`);
|
||||||
|
image = await jimp.read(image);
|
||||||
|
image.flip(horizontal, vertical);
|
||||||
|
return await image.getBufferAsync(`image/png`);
|
||||||
|
}
|
||||||
|
};
|
97
typings/index.d.ts
vendored
97
typings/index.d.ts
vendored
@@ -10,22 +10,62 @@ export class Blur extends ImageGenerator {
|
|||||||
getImage(avatar: string, level?: number): Promise<Buffer>;
|
getImage(avatar: string, level?: number): Promise<Buffer>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class Gay extends DefaultImageGenerator { }
|
||||||
|
|
||||||
|
export class Greyscale extends DefaultImageGenerator { }
|
||||||
|
|
||||||
|
export class Invert extends DefaultImageGenerator { }
|
||||||
|
|
||||||
|
export class Sepia extends DefaultImageGenerator { }
|
||||||
|
|
||||||
export class Blink extends ImageGenerator {
|
export class Blink extends ImageGenerator {
|
||||||
getImage(avatar: string, avatar2: string, ...avatars: string[]): Promise<Buffer>;
|
getImage(delay: number, ...avatar: any[]): Promise<Buffer>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class Triggered extends DefaultImageGenerator { }
|
||||||
|
|
||||||
|
export class Ad extends DefaultImageGenerator { }
|
||||||
|
|
||||||
|
export class Affect extends DefaultImageGenerator { }
|
||||||
|
|
||||||
export class Batslap extends ImageGenerator {
|
export class Batslap extends ImageGenerator {
|
||||||
getImage(avatar: string, avatar2: string): Promise<Buffer>;
|
getImage(avatar: string, avatar2: string): Promise<Buffer>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class Beautiful extends DefaultImageGenerator { }
|
||||||
|
|
||||||
export class Bed extends ImageGenerator {
|
export class Bed extends ImageGenerator {
|
||||||
getImage(avatar: string, avatar2: string): Promise<Buffer>;
|
getImage(avatar: string, avatar2: string): Promise<Buffer>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class Bobross extends DefaultImageGenerator { }
|
||||||
|
|
||||||
|
export class Clown extends DefaultImageGenerator { }
|
||||||
|
|
||||||
|
export class ConfusedStonk extends DefaultImageGenerator { }
|
||||||
|
|
||||||
|
export class Deepfry extends DefaultImageGenerator { }
|
||||||
|
|
||||||
|
export class Delete extends DefaultImageGenerator { }
|
||||||
|
|
||||||
|
export class DiscordBlack extends DefaultImageGenerator { }
|
||||||
|
|
||||||
|
export class DiscordBlue extends DefaultImageGenerator { }
|
||||||
|
|
||||||
export class DoubleStonk extends ImageGenerator {
|
export class DoubleStonk extends ImageGenerator {
|
||||||
getImage(avatar: string, avatar2: string): Promise<Buffer>;
|
getImage(avatar: string, avatar2: string): Promise<Buffer>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class Facepalm extends DefaultImageGenerator { }
|
||||||
|
|
||||||
|
export class Heartbreaking extends DefaultImageGenerator { }
|
||||||
|
|
||||||
|
export class Hitler extends DefaultImageGenerator { }
|
||||||
|
|
||||||
|
export class Jail extends DefaultImageGenerator { }
|
||||||
|
|
||||||
|
export class Karaba extends DefaultImageGenerator { }
|
||||||
|
|
||||||
export class Kiss extends ImageGenerator {
|
export class Kiss extends ImageGenerator {
|
||||||
getImage(avatar: string, avatar2: string): Promise<Buffer>;
|
getImage(avatar: string, avatar2: string): Promise<Buffer>;
|
||||||
}
|
}
|
||||||
@@ -34,6 +74,12 @@ export class LisaPresentation extends ImageGenerator {
|
|||||||
getImage(text: string): Promise<Buffer>;
|
getImage(text: string): Promise<Buffer>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class Mikkelsen extends DefaultImageGenerator { }
|
||||||
|
|
||||||
|
export class Mms extends DefaultImageGenerator { }
|
||||||
|
|
||||||
|
export class NotStonk extends DefaultImageGenerator { }
|
||||||
|
|
||||||
export class Podium extends ImageGenerator {
|
export class Podium extends ImageGenerator {
|
||||||
getImage(
|
getImage(
|
||||||
avatar: string,
|
avatar: string,
|
||||||
@@ -45,41 +91,38 @@ export class Podium extends ImageGenerator {
|
|||||||
): Promise<Buffer>;
|
): Promise<Buffer>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class Poutine extends DefaultImageGenerator { }
|
||||||
|
|
||||||
|
export class Rip extends DefaultImageGenerator { }
|
||||||
|
|
||||||
|
export class Snyder extends DefaultImageGenerator { }
|
||||||
|
|
||||||
export class Spank extends ImageGenerator {
|
export class Spank extends ImageGenerator {
|
||||||
getImage(avatar: string, avatar2: string): Promise<Buffer>;
|
getImage(avatar: string, avatar2: string): Promise<Buffer>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class Stonk extends DefaultImageGenerator { }
|
||||||
|
|
||||||
|
export class Tatoo extends DefaultImageGenerator { }
|
||||||
|
|
||||||
|
export class Thomas extends DefaultImageGenerator { }
|
||||||
|
|
||||||
|
export class Trash extends DefaultImageGenerator { }
|
||||||
|
|
||||||
export class Wanted extends ImageGenerator {
|
export class Wanted extends ImageGenerator {
|
||||||
getImage(avatar: string, currency: string): Promise<Buffer>;
|
getImage(avatar: string, currency: string): Promise<Buffer>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class Circle extends DefaultImageGenerator { }
|
||||||
|
|
||||||
export class Color extends ImageGenerator {
|
export class Color extends ImageGenerator {
|
||||||
getImage(color: string): Promise<Buffer>;
|
getImage(color: string): Promise<Buffer>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Gay extends DefaultImageGenerator {}
|
export class Denoise extends ImageGenerator {
|
||||||
export class Greyscale extends DefaultImageGenerator {}
|
getImage(avatar: string, level?: number): Promise<Buffer>;
|
||||||
export class Invert extends DefaultImageGenerator {}
|
}
|
||||||
export class Sepia extends DefaultImageGenerator {}
|
|
||||||
export class Triggered extends DefaultImageGenerator {}
|
export class Mirror extends ImageGenerator {
|
||||||
export class Ad extends DefaultImageGenerator {}
|
getImage(avatar: string, horizontal?: boolean, vertical?: boolean): Promise<Buffer>;
|
||||||
export class Affect extends DefaultImageGenerator {}
|
}
|
||||||
export class Beautiful extends DefaultImageGenerator {}
|
|
||||||
export class Bobross extends DefaultImageGenerator {}
|
|
||||||
export class ConfusedStonk extends DefaultImageGenerator {}
|
|
||||||
export class Delete extends DefaultImageGenerator {}
|
|
||||||
export class DiscordBlack extends DefaultImageGenerator {}
|
|
||||||
export class DiscordBlue extends DefaultImageGenerator {}
|
|
||||||
export class Facepalm extends DefaultImageGenerator {}
|
|
||||||
export class Hitler extends DefaultImageGenerator {}
|
|
||||||
export class Jail extends DefaultImageGenerator {}
|
|
||||||
export class Karaba extends DefaultImageGenerator {}
|
|
||||||
export class Mms extends DefaultImageGenerator {}
|
|
||||||
export class NotStonk extends DefaultImageGenerator {}
|
|
||||||
export class Poutine extends DefaultImageGenerator {}
|
|
||||||
export class Rip extends DefaultImageGenerator {}
|
|
||||||
export class Stonk extends DefaultImageGenerator {}
|
|
||||||
export class Tatoo extends DefaultImageGenerator {}
|
|
||||||
export class Thomas extends DefaultImageGenerator {}
|
|
||||||
export class Trash extends DefaultImageGenerator {}
|
|
||||||
export class Circle extends DefaultImageGenerator {}
|
|
||||||
|
Reference in New Issue
Block a user