Compare commits
2 Commits
5830a76096
...
1d6ac1067f
Author | SHA1 | Date |
---|---|---|
Mr¤KayJayDee | 1d6ac1067f | 2 years ago |
Mr¤KayJayDee | fbdedebefd | 2 years ago |
@ -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…
Reference in New Issue