2019-09-13 20:02:41 +00:00
|
|
|
const gm = require("gm").subClass({
|
|
|
|
imageMagick: true
|
|
|
|
});
|
|
|
|
const gmToBuffer = require("../utils/gmbuffer.js");
|
|
|
|
|
|
|
|
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 add some magik!`;
|
2020-01-09 01:10:26 +00:00
|
|
|
if (image.type === "gif") return `${message.author.mention}, this command doesn't work with GIFs!`;
|
2019-09-13 20:02:41 +00:00
|
|
|
const processMessage = await message.channel.createMessage("<a:processing:479351417102925854> Processing... This might take a while");
|
2019-11-11 20:54:19 +00:00
|
|
|
gm(image.data).resize(800, 800).stream((error, stream) => {
|
2019-12-10 15:53:43 +00:00
|
|
|
if (error) throw error;
|
2019-09-13 20:02:41 +00:00
|
|
|
gm(stream).out("-liquid-rescale", "400x400").stream(async (error, stream2) => {
|
2019-12-10 15:53:43 +00:00
|
|
|
if (error) throw error;
|
2019-09-13 20:02:41 +00:00
|
|
|
const data = gm(stream2).out("-liquid-rescale", "1200x1200");
|
|
|
|
const resultBuffer = await gmToBuffer(data);
|
|
|
|
await processMessage.delete();
|
|
|
|
return message.channel.createMessage("", {
|
|
|
|
file: resultBuffer,
|
|
|
|
name: `magik.${image.type}`
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.aliases = ["imagemagic", "imagemagick", "imagemagik", "magic", "magick", "cas", "liquid"];
|
2019-12-02 20:47:22 +00:00
|
|
|
exports.category = 5;
|
|
|
|
exports.help = "Adds a content aware scale effect to an image";
|