Fixed issues with haah, hooh, waaw, and woow relating to gifs

This commit is contained in:
TheEssem 2020-02-04 12:46:00 -06:00
parent d3e59228d2
commit d71fcb5ea3
4 changed files with 20 additions and 20 deletions

View File

@ -9,16 +9,16 @@ exports.run = async (message) => {
message.channel.sendTyping(); message.channel.sendTyping();
const image = await require("../utils/imagedetect.js")(message); const image = await require("../utils/imagedetect.js")(message);
if (image === undefined) return `${message.author.mention}, you need to provide an image to mirror!`; 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 data = `/tmp/${Math.random().toString(36).substring(2, 15)}.miff`;
const data2 = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`; const data2 = `/tmp/${Math.random().toString(36).substring(2, 15)}.miff`;
gm(image.data).size((error, size) => { gm(image.data).size((error, size) => {
if (error) throw error; 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; if (error) throw error;
gm(data2).flop().write(data, async (error) => { gm(data2).flop().write(data, async (error) => {
if (error) throw 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 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); const resultBuffer = await gmToBuffer(command, image.type);
return message.channel.createMessage("", { return message.channel.createMessage("", {
file: resultBuffer, file: resultBuffer,
name: `haah.${image.type}` name: `haah.${image.type}`

View File

@ -9,16 +9,16 @@ exports.run = async (message) => {
message.channel.sendTyping(); message.channel.sendTyping();
const image = await require("../utils/imagedetect.js")(message); const image = await require("../utils/imagedetect.js")(message);
if (image === undefined) return `${message.author.mention}, you need to provide an image to mirror!`; 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 data = `/tmp/${Math.random().toString(36).substring(2, 15)}.miff`;
const data2 = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`; const data2 = `/tmp/${Math.random().toString(36).substring(2, 15)}.miff`;
gm(image.data).size((error, size) => { gm(image.data).size((error, size) => {
if (error) throw error; 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; if (error) throw error;
gm(data2).flip().write(data, async (error) => { gm(data2).flip().write(data, async (error) => {
if (error) throw 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 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); const resultBuffer = await gmToBuffer(command, image.type);
return message.channel.createMessage("", { return message.channel.createMessage("", {
file: resultBuffer, file: resultBuffer,
name: `hooh.${image.type}` name: `hooh.${image.type}`

View File

@ -9,16 +9,16 @@ exports.run = async (message) => {
message.channel.sendTyping(); message.channel.sendTyping();
const image = await require("../utils/imagedetect.js")(message); const image = await require("../utils/imagedetect.js")(message);
if (image === undefined) return `${message.author.mention}, you need to provide an image to mirror!`; 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 data = `/tmp/${Math.random().toString(36).substring(2, 15)}.miff`;
const data2 = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`; const data2 = `/tmp/${Math.random().toString(36).substring(2, 15)}.miff`;
gm(image.data).size((error, size) => { gm(image.data).size((error, size) => {
if (error) throw error; 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; if (error) throw error;
gm(data2).flop().write(data, async (error) => { gm(data2).flop().write(data, async (error) => {
if (error) throw 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 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); const resultBuffer = await gmToBuffer(command, image.type);
return message.channel.createMessage("", { return message.channel.createMessage("", {
file: resultBuffer, file: resultBuffer,
name: `waaw.${image.type}` name: `waaw.${image.type}`

View File

@ -9,16 +9,16 @@ exports.run = async (message) => {
message.channel.sendTyping(); message.channel.sendTyping();
const image = await require("../utils/imagedetect.js")(message); const image = await require("../utils/imagedetect.js")(message);
if (image === undefined) return `${message.author.mention}, you need to provide an image to mirror!`; 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 data = `/tmp/${Math.random().toString(36).substring(2, 15)}.miff`;
const data2 = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`; const data2 = `/tmp/${Math.random().toString(36).substring(2, 15)}.miff`;
gm(image.data).size((error, size) => { gm(image.data).size((error, size) => {
if (error) throw error; 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; if (error) throw error;
gm(data2).flip().write(data, async (error) => { gm(data2).flip().write(data, async (error) => {
if (error) throw 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 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); const resultBuffer = await gmToBuffer(command, image.type);
return message.channel.createMessage("", { return message.channel.createMessage("", {
file: resultBuffer, file: resultBuffer,
name: `woow.${image.type}` name: `woow.${image.type}`