Denoice + mirror

main
Mr¤KayJayDee 2 years ago
parent fbdedebefd
commit 1d6ac1067f

@ -352,8 +352,20 @@ bot.login("super_secret_token");
![Color](https://imgur.com/40tMwfe.png) ![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 # Changelog
## v1.4.23
- Fixed import issue
- Added Denoise()
- Added Mirror()
## v1.4.22 ## v1.4.22
- Fixed some bugs - Fixed some bugs

@ -1,6 +1,6 @@
{ {
"name": "discord-image-generation", "name": "discord-image-generation",
"version": "1.4.22", "version": "1.4.23",
"description": "discord-image-generation is a powerful 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",
"scripts": { "scripts": {

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

@ -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