Added -layers optimize to every image command

This commit is contained in:
TheEssem 2020-02-20 08:22:05 -06:00
parent a7746cc865
commit 328d36d1ea
20 changed files with 21 additions and 21 deletions

View File

@ -8,7 +8,7 @@ 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 a 9GAG watermark!`;
const watermark = "./assets/images/9gag.png";
const data = gm(image.path).coalesce().out("null:").out(watermark).gravity("East").out("-layers", "composite").out("-layers", "optimize");
const data = gm(image.path).coalesce().out("null:").out(watermark).gravity("East").out("-layers", "composite");
const buffer = await gmToBuffer(data, image.outputType);
return message.channel.createMessage("", {
file: buffer,

View File

@ -10,7 +10,7 @@ exports.run = async (message) => {
const watermark = "./assets/images/bandicam.png";
gm(image.path).size(async (error, size) => {
if (error) throw error;
const data = gm(image.path).coalesce().out("null:").out(watermark).gravity("North").resize(null, size.height).out("-layers", "composite").out("-layers", "optimize");
const data = gm(image.path).coalesce().out("null:").out(watermark).gravity("North").resize(null, size.height).out("-layers", "composite");
const buffer = await gmToBuffer(data, image.outputType);
return message.channel.createMessage("", {
file: buffer,

View File

@ -17,7 +17,7 @@ exports.run = async (message, args) => {
if (error) throw error;
gm(output).gravity("Center").trim().out("+repage").extent(size.width, size2.height + (size.width / 10)).stream(async (error, output2) => {
if (error) throw error;
const command3 = 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").out("-layers", "optimize");
const command3 = 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");
const outputFinal = await gmToBuffer(command3, image.outputType);
await processMessage.delete();
//return upload(message, outputFinal, `caption.${image.type}`);

View File

@ -10,7 +10,7 @@ exports.run = async (message) => {
const watermark = "./assets/images/deviantart.png";
gm(image.path).size(async (error, size) => {
if (error) throw error;
const data = gm(image.path).coalesce().out("null:").out(watermark).gravity("Center").resize(null, size.height).out("-layers", "composite").out("-layers", "optimize");
const data = gm(image.path).coalesce().out("null:").out(watermark).gravity("Center").resize(null, size.height).out("-layers", "composite");
const buffer = await gmToBuffer(data, image.outputType);
return message.channel.createMessage("", {
file: buffer,

View File

@ -10,7 +10,7 @@ exports.run = async (message) => {
const watermark = "./assets/images/funky.png";
gm(image.path).size(async (error, size) => {
if (error) throw error;
const data = gm(image.path).coalesce().out("null:").out(watermark).gravity("NorthEast").resize(null, size.height).out("-layers", "composite").out("-layers", "optimize");
const data = gm(image.path).coalesce().out("null:").out(watermark).gravity("NorthEast").resize(null, size.height).out("-layers", "composite");
const buffer = await gmToBuffer(data, image.outputType);
return message.channel.createMessage("", {
file: buffer,

View File

@ -8,7 +8,7 @@ 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 make a GameXplain thumbnail meme!`;
const template = "./assets/images/gamexplain.png";
const command = gm(template).background("white").out("null:").out("(").out(image.path).coalesce().out("-virtual-pixel", "transparent").resize("1181x571!").out(")").compose("over").gravity("Center").out("-geometry", "+0+40").out("-layers", "composite").out("-layers", "optimize");
const command = gm(template).background("white").out("null:").out("(").out(image.path).coalesce().out("-virtual-pixel", "transparent").resize("1181x571!").out(")").compose("over").gravity("Center").out("-geometry", "+0+40").out("-layers", "composite");
const buffer = await gmToBuffer(command, image.outputType);
return message.channel.createMessage("", {
file: buffer,

View File

@ -17,7 +17,7 @@ exports.run = async (message) => {
if (error) throw error;
gm(data2).flop().write(data, async (error) => {
if (error) throw error;
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 command = gm(data2).extent(size.width, size.height).out("null:").out(data).geometry(`+${size.width / 2}+0`).out("-layers", "Composite");
const buffer = await gmToBuffer(command, image.outputType);
return message.channel.createMessage("", {
file: buffer,

View File

@ -17,7 +17,7 @@ exports.run = async (message) => {
if (error) throw error;
gm(data2).flip().write(data, async (error) => {
if (error) throw error;
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 command = gm(data2).extent(size.width, size.height).out("null:").out(data).geometry(`+0+${size.height / 2}`).out("-layers", "Composite");
const buffer = await gmToBuffer(command, image.outputType);
return message.channel.createMessage("", {
file: buffer,

View File

@ -10,7 +10,7 @@ exports.run = async (message) => {
const watermark = "./assets/images/hypercam.png";
gm(image.path).size(async (error, size) => {
if (error) throw error;
const data = gm(image.path).coalesce().out("null:").out(watermark).gravity("NorthWest").resize(null, size.height).out("-layers", "composite").out("-layers", "optimize");
const data = gm(image.path).coalesce().out("null:").out(watermark).gravity("NorthWest").resize(null, size.height).out("-layers", "composite");
const buffer = await gmToBuffer(data, image.outputType);
return message.channel.createMessage("", {
file: buffer,

View File

@ -10,7 +10,7 @@ exports.run = async (message) => {
const watermark = "./assets/images/ifunny.png";
gm(image.path).size(async (error, size) => {
if (error) throw error;
const data = gm(image.path).coalesce().out("null:").out(watermark).gravity("South").resize(size.width, null).out("-layers", "composite").out("-layers", "optimize");
const data = gm(image.path).coalesce().out("null:").out(watermark).gravity("South").resize(size.width, null).out("-layers", "composite");
const buffer = await gmToBuffer(data, image.outputType);
return message.channel.createMessage("", {
file: buffer,

View File

@ -20,7 +20,7 @@ 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, "\\&amp;").replace(/>/g, "\\&gt;").replace(/</g, "\\&lt;").replace(/"/g, "\\&quot;").replace(/'/g, "\\&apos;") : " "}</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).out("-coalesce").out("null:").gravity("North").out(file2).out("-layers", "composite").out("null:").gravity("South").out(file3).out("-layers", "composite").out("-layers", "optimize");
const data = gm(file).out("-coalesce").out("null:").gravity("North").out(file2).out("-layers", "composite").out("null:").gravity("South").out(file3).out("-layers", "composite");
const buffer = await gmToBuffer(data, image.outputType);
return message.channel.createMessage("", {
file: buffer,

View File

@ -11,7 +11,7 @@ exports.run = async (message) => {
let resultBuffer;
gm(image.path).size(async (error, size) => {
if (error) throw error;
const command = gm(image.path).coalesce().background("white").extent(size.width, size.height + 15).out("null:").out(watermark).gravity("SouthEast").compose("over").out("-layers", "composite").out("-layers", "optimize");
const command = gm(image.path).coalesce().background("white").extent(size.width, size.height + 15).out("null:").out(watermark).gravity("SouthEast").compose("over").out("-layers", "composite");
const output = await gmToBuffer(command, image.outputType);
gm(output).size(async (error, size2) => {
if (error) throw error;

View File

@ -8,7 +8,7 @@ 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 make a Scott the Woz TV meme!`;
const template = "./assets/images/scott.png";
const command = gm(template).out("null:").out("(").out(image.path).coalesce().out("-virtual-pixel", "transparent").resize("415x234!").out("+distort", "Perspective", "0,0 129,187 415,0 517,182 415,234 517,465 0,234 132,418").out(")").compose("over").gravity("Center").geometry("-238-98").out("-layers", "composite").out("-layers", "optimize");
const command = gm(template).out("null:").out("(").out(image.path).coalesce().out("-virtual-pixel", "transparent").resize("415x234!").out("+distort", "Perspective", "0,0 129,187 415,0 517,182 415,234 517,465 0,234 132,418").out(")").compose("over").gravity("Center").geometry("-238-98").out("-layers", "composite");
const buffer = await gmToBuffer(command, image.outputType);
return message.channel.createMessage("", {
file: buffer,

View File

@ -10,7 +10,7 @@ exports.run = async (message) => {
const watermark = "./assets/images/shutterstock.png";
gm(image.path).size(async (error, size) => {
if (error) throw error;
const command = gm(image.path).coalesce().out("null:").out(watermark).gravity("Center").resize(null, size.height).out("-layers", "composite").out("-layers", "optimize");
const command = gm(image.path).coalesce().out("null:").out(watermark).gravity("Center").resize(null, size.height).out("-layers", "composite");
const buffer = await gmToBuffer(command, image.outputType);
return message.channel.createMessage("", {
file: buffer,

View File

@ -21,7 +21,7 @@ exports.run = async (message) => {
});
} else {
const numbers = (await util.promisify(exec)(`seq 0 2 ${value.Scene.length}`)).stdout.split("\n").join(",");
const data = gm().out("(").out(image.path).coalesce().out(")").out("-delete", numbers).out("-layers", "optimize");
const data = gm().out("(").out(image.path).coalesce().out(")").out("-delete", numbers);
const buffer = await gmToBuffer(data, image.outputType);
return message.channel.createMessage("", {
file: buffer,

View File

@ -8,7 +8,7 @@ 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 make a Trump meme!`;
const template = "./assets/images/trump.png";
const command = gm(template).background("white").out("null:").out("(").out(image.path).coalesce().out("-virtual-pixel", "transparent").resize("365x179!").out("+distort", "Perspective", "0,0 207,268 365,0 548,271 365,179 558,450 0,179 193,450").out(")").compose("over").gravity("Center").geometry("-217-135").out("-layers", "composite").out("-layers", "optimize");
const command = gm(template).background("white").out("null:").out("(").out(image.path).coalesce().out("-virtual-pixel", "transparent").resize("365x179!").out("+distort", "Perspective", "0,0 207,268 365,0 548,271 365,179 558,450 0,179 193,450").out(")").compose("over").gravity("Center").geometry("-217-135").out("-layers", "composite");
const buffer = await gmToBuffer(command, image.outputType);
return message.channel.createMessage("", {
file: buffer,

View File

@ -17,7 +17,7 @@ exports.run = async (message) => {
if (error) throw error;
gm(data2).flop().write(data, async (error) => {
if (error) throw error;
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 command = gm(data2).extent(size.width, size.height).out("null:").out(data).geometry(`+${size.width / 2}+0`).out("-layers", "Composite");
const buffer = await gmToBuffer(command, image.outputType);
return message.channel.createMessage("", {
file: buffer,

View File

@ -8,7 +8,7 @@ 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 make a "who did this" meme!`;
const template = "./assets/images/whodidthis.png";
const command = gm(template).coalesce().out("null:").out(image.path).gravity("Center").resize("374x374>").out("-layers", "composite").out("-layers", "optimize");
const command = gm(template).coalesce().out("null:").out(image.path).gravity("Center").resize("374x374>").out("-layers", "composite");
const buffer = await gmToBuffer(command, image.outputType);
return message.channel.createMessage("", {
file: buffer,

View File

@ -17,7 +17,7 @@ exports.run = async (message) => {
if (error) throw error;
gm(data2).flip().write(data, async (error) => {
if (error) throw error;
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 command = gm(data2).extent(size.width, size.height).out("null:").out(data).geometry(`+0+${size.height / 2}`).out("-layers", "Composite");
const buffer = await gmToBuffer(command, image.outputType);
return message.channel.createMessage("", {
file: buffer,

View File

@ -3,7 +3,7 @@
module.exports = (data, format) => {
return new Promise((resolve, reject) => {
if (format) {
data.stream(format, (err, stdout, stderr) => {
data.out("-layers", "optimize").stream(format, (err, stdout, stderr) => {
if (err) return reject(err);
const chunks = [];
stdout.on("data", (chunk) => {
@ -19,7 +19,7 @@ module.exports = (data, format) => {
});
});
} else {
data.stream((err, stdout, stderr) => {
data.out("-layers", "optimize").stream((err, stdout, stderr) => {
if (err) return reject(err);
const chunks = [];
stdout.on("data", (chunk) => {