23 lines
965 B
JavaScript
23 lines
965 B
JavaScript
|
const gm = require("gm").subClass({
|
||
|
imageMagick: true
|
||
|
});
|
||
|
const gmToBuffer = require("../utils/gmbuffer.js");
|
||
|
const fetch = require("node-fetch");
|
||
|
|
||
|
exports.run = async (message) => {
|
||
|
const image = await require("../utils/imagedetect.js")(message);
|
||
|
if (image === undefined) return `${message.author.mention}, you need to provide an image to make a wall from!`;
|
||
|
message.channel.sendTyping();
|
||
|
const imageData = await fetch(image.url);
|
||
|
const imageBuffer = await imageData.buffer();
|
||
|
gm(imageBuffer).resize(128).stream(async (error, output) => {
|
||
|
if (error) console.error;
|
||
|
const data = gm(output).virtualPixel("tile").matteColor("none").out("-background", "none").resize("512x512!").out("-distort").out("Perspective").out("0,0,57,42 0,128,63,130 128,0,140,60 128,128,140,140");
|
||
|
const resultBuffer = await gmToBuffer(data);
|
||
|
return message.channel.createMessage("", {
|
||
|
file: resultBuffer,
|
||
|
name: `wall.${image.type}`
|
||
|
});
|
||
|
});
|
||
|
};
|