From d71fcb5ea3cfb95166ebb08031a94c9c43b72c04 Mon Sep 17 00:00:00 2001 From: TheEssem Date: Tue, 4 Feb 2020 12:46:00 -0600 Subject: [PATCH] Fixed issues with haah, hooh, waaw, and woow relating to gifs --- commands/haah.js | 10 +++++----- commands/hooh.js | 10 +++++----- commands/waaw.js | 10 +++++----- commands/woow.js | 10 +++++----- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/commands/haah.js b/commands/haah.js index 9358185..5b93648 100644 --- a/commands/haah.js +++ b/commands/haah.js @@ -9,16 +9,16 @@ 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 mirror!`; - const data = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`; - const data2 = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`; + const data = `/tmp/${Math.random().toString(36).substring(2, 15)}.miff`; + const data2 = `/tmp/${Math.random().toString(36).substring(2, 15)}.miff`; gm(image.data).size((error, size) => { if (error) throw error; - gm(image.data).gravity("West").crop("50%", 0).out("+repage").write(data2, (error) => { + gm(image.data).coalesce().gravity("West").crop("50%", 0).out("+repage").write(data2, (error) => { if (error) throw error; gm(data2).flop().write(data, async (error) => { if (error) throw error; - const command = gm(data2).out("-repage", `${size.width}x${size.height}`).coalesce().out("null:").out("(").out(data).coalesce().out(")").geometry(`+${size.width / 2}+0`).out("-layers", "Composite").out("-layers", "optimize"); - const resultBuffer = await gmToBuffer(command); + const command = gm(data2).extent(size.width, size.height).out("null:").out(data).geometry(`+${size.width / 2}+0`).out("-layers", "Composite").out("-layers", "optimize"); + const resultBuffer = await gmToBuffer(command, image.type); return message.channel.createMessage("", { file: resultBuffer, name: `haah.${image.type}` diff --git a/commands/hooh.js b/commands/hooh.js index b81d315..08621f1 100644 --- a/commands/hooh.js +++ b/commands/hooh.js @@ -9,16 +9,16 @@ 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 mirror!`; - const data = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`; - const data2 = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`; + const data = `/tmp/${Math.random().toString(36).substring(2, 15)}.miff`; + const data2 = `/tmp/${Math.random().toString(36).substring(2, 15)}.miff`; gm(image.data).size((error, size) => { if (error) throw error; - gm(image.data).gravity("South").crop(0, "50%").out("+repage").write(data2, (error) => { + gm(image.data).coalesce().gravity("South").crop(0, "50%").out("+repage").write(data2, (error) => { if (error) throw error; gm(data2).flip().write(data, async (error) => { if (error) throw error; - const command = gm(data).out("-repage", `${size.width}x${size.height}`).coalesce().out("null:").out("(").out(data2).coalesce().out(")").geometry(`+0+${size.height / 2}`).out("-layers", "Composite").out("-layers", "optimize"); - const resultBuffer = await gmToBuffer(command); + const command = gm(data2).extent(size.width, size.height).out("null:").out(data).geometry(`+0+${size.height / 2}`).out("-layers", "Composite").out("-layers", "Optimize"); + const resultBuffer = await gmToBuffer(command, image.type); return message.channel.createMessage("", { file: resultBuffer, name: `hooh.${image.type}` diff --git a/commands/waaw.js b/commands/waaw.js index 7a997fd..fbafa8c 100644 --- a/commands/waaw.js +++ b/commands/waaw.js @@ -9,16 +9,16 @@ 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 mirror!`; - const data = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`; - const data2 = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`; + const data = `/tmp/${Math.random().toString(36).substring(2, 15)}.miff`; + const data2 = `/tmp/${Math.random().toString(36).substring(2, 15)}.miff`; gm(image.data).size((error, size) => { if (error) throw error; - gm(image.data).gravity("East").crop("50%", 0).out("+repage").write(data2, (error) => { + gm(image.data).coalesce().gravity("East").crop("50%", 0).out("+repage").write(data2, (error) => { if (error) throw error; gm(data2).flop().write(data, async (error) => { if (error) throw error; - const command = gm(data).out("-repage", `${size.width}x${size.height}`).coalesce().out("null:").out("(").out(data2).coalesce().out(")").geometry(`+${size.width / 2}+0`).out("-layers", "Composite").out("-layers", "optimize"); - const resultBuffer = await gmToBuffer(command); + const command = gm(data2).extent(size.width, size.height).out("null:").out(data).geometry(`+${size.width / 2}+0`).out("-layers", "Composite").out("-layers", "optimize"); + const resultBuffer = await gmToBuffer(command, image.type); return message.channel.createMessage("", { file: resultBuffer, name: `waaw.${image.type}` diff --git a/commands/woow.js b/commands/woow.js index c47a4f3..48d4343 100644 --- a/commands/woow.js +++ b/commands/woow.js @@ -9,16 +9,16 @@ 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 mirror!`; - const data = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`; - const data2 = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`; + const data = `/tmp/${Math.random().toString(36).substring(2, 15)}.miff`; + const data2 = `/tmp/${Math.random().toString(36).substring(2, 15)}.miff`; gm(image.data).size((error, size) => { if (error) throw error; - gm(image.data).gravity("North").crop(0, "50%").out("+repage").write(data2, (error) => { + gm(image.data).coalesce().gravity("North").crop(0, "50%").out("+repage").write(data2, (error) => { if (error) throw error; gm(data2).flip().write(data, async (error) => { if (error) throw error; - const command = gm(data2).out("-repage", `${size.width}x${size.height}`).coalesce().out("null:").out("(").out(data).coalesce().out(")").geometry(`+0+${size.height / 2}`).out("-layers", "Composite").out("-layers", "optimize"); - const resultBuffer = await gmToBuffer(command); + const command = gm(data2).extent(size.width, size.height).out("null:").out(data).geometry(`+0+${size.height / 2}`).out("-layers", "Composite").out("-layers", "optimize"); + const resultBuffer = await gmToBuffer(command, image.type); return message.channel.createMessage("", { file: resultBuffer, name: `woow.${image.type}`