Fixed some more bugs related to meme
This commit is contained in:
parent
58d1292c35
commit
f4830db1ec
1 changed files with 4 additions and 4 deletions
|
@ -9,10 +9,10 @@ exports.run = async (message, args) => {
|
|||
if (image === undefined) return `${message.author.mention}, you need to provide an image to generate a meme!`;
|
||||
if (args.length === 0) return `${message.author.mention}, you need to provide some text to generate a meme!`;
|
||||
const [topText, bottomText] = args.join(" ").split(",").map(elem => elem.trim());
|
||||
const file = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`;
|
||||
const file = `/tmp/${Math.random().toString(36).substring(2, 15)}.miff`;
|
||||
const file2 = `/tmp/${Math.random().toString(36).substring(2, 15)}.png`;
|
||||
const file3 = `/tmp/${Math.random().toString(36).substring(2, 15)}.png`;
|
||||
gm(image.data).resize(600, 600).noProfile().write(file, (error) => {
|
||||
gm(image.data).out("-coalesce").resize(600, 600).noProfile().write(file, (error) => {
|
||||
if (error) throw error;
|
||||
gm(file).size((error, size) => {
|
||||
if (error) throw error;
|
||||
|
@ -20,8 +20,8 @@ exports.run = async (message, args) => {
|
|||
if (error) throw error;
|
||||
gm().out("-size", size.width).background("none").gravity("Center").out("(", "(").font("Impact").out("-pointsize", 40).out(`pango:<span foreground='white'>${bottomText ? bottomText.toUpperCase().replace(/&/g, "\\&").replace(/>/g, "\\>").replace(/</g, "\\<").replace(/"/g, "\\"").replace(/'/g, "\\'") : " "}</span>`).out(")", "(", "+clone").out("-channel", "A").out("-morphology", "EdgeOut", "Octagon", "+channel", "+level-colors", "black", ")").compose("DstOver").out(")", "-composite").write(file3, async (error) => {
|
||||
if (error) throw error;
|
||||
const data = gm(file).coalesce().out("null:").gravity("North").out(file2).out("-layers", "composite").out("null:").gravity("South").out(file3).out("-layers", "composite").out("-layers", "optimize");
|
||||
const resultBuffer = await gmToBuffer(data);
|
||||
const data = gm(file).out("-coalesce").out("null:").gravity("North").out(file2).out("-layers", "composite").out("null:").gravity("South").out(file3).out("-layers", "composite").out("-layers", "optimize");
|
||||
const resultBuffer = await gmToBuffer(data, image.type);
|
||||
return message.channel.createMessage("", {
|
||||
file: resultBuffer,
|
||||
name: `meme.${image.type}`
|
||||
|
|
Loading…
Reference in a new issue