2020-01-08 01:17:04 +00:00
|
|
|
const gm = require("gm").subClass({
|
|
|
|
imageMagick: true
|
|
|
|
});
|
2020-02-18 20:44:39 +00:00
|
|
|
//const upload = require("../utils/upload.js");
|
2020-01-08 01:17:04 +00:00
|
|
|
|
|
|
|
exports.run = async (message, args) => {
|
|
|
|
const image = await require("../utils/imagedetect.js")(message);
|
|
|
|
if (image === undefined) return `${message.author.mention}, you need to provide an image/GIF to add a caption!`;
|
2020-01-09 01:10:26 +00:00
|
|
|
if (args.length === 0) return `${message.author.mention}, you need to provide some text to add a caption!`;
|
2020-01-08 01:17:04 +00:00
|
|
|
const processMessage = await message.channel.createMessage("<a:processing:479351417102925854> Processing... This might take a while");
|
2020-03-03 21:20:03 +00:00
|
|
|
const output = await gm(image.path).out("-size", "%[fx:w]x").background("white").fill("black").font("./assets/caption.otf", "%[fx:w/10]").out("-delete", "0--1").gravity("Center").out(`caption:${args.join(" ")}`).bufferPromise("png");
|
|
|
|
const output2 = await gm(output).out(image.path).gravity("Center").trim().out("+repage").extent("%[fx:v.w]", "%[fx:u.h + ( v.w/10 )]").out("-delete", "1--1").streamPromise();
|
2020-02-25 20:45:47 +00:00
|
|
|
const outputFinal = await gm(output2).out("-alpha", "set").background("none").out("(").out(image.path).out("-coalesce").out(")").colorspace("sRGB").out("-set", "page", "%[fx:u.w]x%[fx:u.h+v.h]+%[fx:t?(u.w-v.w)/2:0]+%[fx:t?u.h:0]").out("-coalesce").out("null:").out("-insert", 1).out("-layers", "composite").bufferPromise(image.type);
|
2020-02-21 00:26:49 +00:00
|
|
|
await processMessage.delete();
|
|
|
|
//return upload(message, outputFinal, `caption.${image.type}`);
|
|
|
|
return message.channel.createMessage("", {
|
|
|
|
file: outputFinal,
|
2020-02-25 20:45:47 +00:00
|
|
|
name: `caption.${image.type}`
|
2020-01-08 01:17:04 +00:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.aliases = ["gifc", "gcaption", "ifcaption", "ifunnycaption"];
|
|
|
|
exports.category = 5;
|
|
|
|
exports.help = "Adds a caption to an image/GIF";
|