Compare commits

..

2 Commits

Author SHA1 Message Date
Mr¤KayJayDee 1d6ac1067f Denoice + mirror 2 years ago
Mr¤KayJayDee fbdedebefd Fixed some bugs 2 years ago

@ -352,8 +352,23 @@ bot.login("super_secret_token");
![Color](https://imgur.com/40tMwfe.png)
- ``new DIG.Denoise().getImage(`<Avatar>`, `<Level>`);``
> Level should be a number
- ``new DIG.Mirror().getImage(`<Avatar>`, `<Level>`);``
![Mirror](https://imgur.com/oaxbVAC.png)
# Changelog
## 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
@ -362,7 +377,7 @@ bot.login("super_secret_token");
- Some fixes
- Added Clown() (thanks to Retrojection#1937)
- Added Deepfry() (thanks to Retrojection#1937)
- Added Hearbreaking() (thanks to Retrojection#1937)
- Added Heartbreaking() (thanks to Retrojection#1937)
- Added Mikkelsen() (thanks to Retrojection#1937)
- Added Snyder() (thanks to Retrojection#1937)

@ -1,6 +1,6 @@
{
"name": "discord-image-generation",
"version": "1.4.21",
"version": "1.4.23",
"description": "discord-image-generation is a powerful module that allow you to generate awesome images.",
"main": "src/index.js",
"scripts": {

@ -1,21 +1,15 @@
const { promisify } = require(`util`);
const fs = require(`fs`);
const path = require(`path`);
const { readdirSync } = require(`fs`);
const { join } = require(`path`);
const readdir = promisify(fs.readdir);
async function optimize() {
for (let type of (await readdir(path.join(__dirname, `module`))).filter(
f => !f.includes(`.`)
)) {
for (let File of (await readdir(path.join(__dirname, `module`, type)))
.filter(file => file !== `index.js` && file.endsWith(`.js`))) {
for (let type of readdirSync(join(__dirname, `module`)).filter(
f => !f.includes(`.`)
)) {
readdirSync(join(__dirname, `module`, type))
.filter(file => file !== `index.js` && file.endsWith(`.js`))
.map(File => {
const Name = File.split(`.`)[0];
exports[
Name.charAt(0).toUpperCase() + Name.slice(1)
] = require(`${__dirname}/module/${type}/${File}`, { lazy: true });
}
}
}
optimize();
] = require(`${__dirname}/module/${type}/${File}`);
});
}

@ -14,7 +14,7 @@ module.exports = class Clown {
}
if (!image) throw new Error(`You must provide an image as an argument`);
let isValid = await validateURL(img1);
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`);

@ -1,11 +1,11 @@
const Jimp = require('jimp');
const { validateURL } = require(`../functions`);
module.exports = class ConfusedStonk {
async getImage(img1) {
if (!img1) return console.error(`You must provide an image as an argument`);
let isValid = await validateURL(img1);
async getImage(image) {
if (!image) return console.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 image1 = await Jimp.read(img1);
const image1 = await Jimp.read(image);
const background = await Jimp.read(`${__dirname}/../../assets/confusedStonk.png`);
image1.resize(400, 400);
const compositeImage = new Jimp(background.getWidth(), background.getHeight(), 0xFFFFFFFF);

@ -7,7 +7,6 @@ module.exports = class Deepfry {
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.resize(500, 500);
image.quality(2)
image.contrast(1);
image.pixelate(2);

@ -1,12 +1,12 @@
const Jimp = require('jimp');
const { validateURL } = require(`../functions`);
module.exports = class DiscordBlack {
async getImage(img1) {
if (!img1) return console.error(`You must provide an image as an argument`);
let isValid = await validateURL(img1);
async getImage(image) {
if (!image) return console.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 background = await Jimp.read(`${__dirname}/../../assets/discordblack.png`);
const image1 = await Jimp.read(img1);
const image1 = await Jimp.read(image);
image1.resize(background.getWidth(), background.getHeight());
const compositeImage = new Jimp(background.getWidth(), background.getHeight(), 0xFFFFFFFF);
compositeImage.composite(image1, 0, 0);

@ -1,12 +1,12 @@
const Jimp = require('jimp');
const { validateURL } = require(`../functions`);
module.exports = class DiscordBlue {
async getImage(img1) {
if (!img1) return console.error(`You must provide an image as an argument`);
let isValid = await validateURL(img1);
async getImage(image) {
if (!image) return console.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 background = await Jimp.read(`${__dirname}/../../assets/discordblue.png`);
const image1 = await Jimp.read(img1);
const image1 = await Jimp.read(image);
image1.resize(background.getWidth(), background.getHeight());
const compositeImage = new Jimp(background.getWidth(), background.getHeight(), 0xFFFFFFFF);
compositeImage.composite(image1, 0, 0);

@ -4,7 +4,7 @@ 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(img1);
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`);

@ -4,7 +4,7 @@ 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(img1);
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`);

@ -14,7 +14,7 @@ module.exports = class Snyder {
}
if (!image) throw new Error(`You must provide an image as an argument`);
let isValid = await validateURL(img1);
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`);

@ -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`);
}
};

@ -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`);
}
};
Loading…
Cancel
Save