mrmBot-Matrix/commands/wall.js

22 lines
902 B
JavaScript
Raw Normal View History

const gm = require("gm").subClass({
imageMagick: true
});
const gmToBuffer = require("../utils/gmbuffer.js");
exports.run = async (message) => {
message.channel.sendTyping();
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!`;
gm(image.data).resize(128).stream(async (error, output) => {
if (error) throw 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}`
});
});
};
exports.category = 5;
exports.help = "Creates a wall from an image";