Added optimization to many image commands, updated packages
This commit is contained in:
parent
51d5f5e5b9
commit
a534e7c4cf
19 changed files with 42 additions and 50 deletions
|
@ -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.data).coalesce().out("null:").out(watermark).gravity("East").out("-layers", "composite");
|
||||
const data = gm(image.data).coalesce().out("null:").out(watermark).gravity("East").out("-layers", "composite").out("-layers", "optimize");
|
||||
const resultBuffer = await gmToBuffer(data);
|
||||
return message.channel.createMessage("", {
|
||||
file: resultBuffer,
|
||||
|
|
|
@ -10,7 +10,7 @@ exports.run = async (message) => {
|
|||
const watermark = "./assets/images/bandicam.png";
|
||||
gm(image.data).size(async (error, size) => {
|
||||
if (error) throw error;
|
||||
const data = gm(image.data).coalesce().out("null:").out(watermark).gravity("North").resize(null, size.height).out("-layers", "composite");
|
||||
const data = gm(image.data).coalesce().out("null:").out(watermark).gravity("North").resize(null, size.height).out("-layers", "composite").out("-layers", "optimize");
|
||||
const resultBuffer = await gmToBuffer(data);
|
||||
return message.channel.createMessage("", {
|
||||
file: resultBuffer,
|
||||
|
|
|
@ -19,7 +19,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(path).out("-coalesce").out(")").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("-loop", "0");
|
||||
const command3 = gm(output2).out("-alpha", "set").background("none").out("(").out(path).out("-coalesce").out(")").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 outputFinal = await gmToBuffer(command3, image.type);
|
||||
await processMessage.delete();
|
||||
return message.channel.createMessage("", {
|
||||
|
|
|
@ -10,7 +10,7 @@ exports.run = async (message) => {
|
|||
const watermark = "./assets/images/deviantart.png";
|
||||
gm(image.data).size(async (error, size) => {
|
||||
if (error) throw error;
|
||||
const data = gm(image.data).coalesce().out("null:").out(watermark).gravity("Center").resize(null, size.height).out("-layers", "composite");
|
||||
const data = gm(image.data).coalesce().out("null:").out(watermark).gravity("Center").resize(null, size.height).out("-layers", "composite").out("-layers", "optimize");
|
||||
const resultBuffer = await gmToBuffer(data);
|
||||
return message.channel.createMessage("", {
|
||||
file: resultBuffer,
|
||||
|
|
|
@ -10,7 +10,7 @@ exports.run = async (message) => {
|
|||
const watermark = "./assets/images/funky.png";
|
||||
gm(image.data).size(async (error, size) => {
|
||||
if (error) throw error;
|
||||
const data = gm(image.data).coalesce().out("null:").out(watermark).gravity("NorthEast").resize(null, size.height).out("-layers", "composite");
|
||||
const data = gm(image.data).coalesce().out("null:").out(watermark).gravity("NorthEast").resize(null, size.height).out("-layers", "composite").out("-layers", "optimize");
|
||||
const resultBuffer = await gmToBuffer(data);
|
||||
return message.channel.createMessage("", {
|
||||
file: resultBuffer,
|
||||
|
|
|
@ -11,7 +11,7 @@ exports.run = async (message) => {
|
|||
const template = "./assets/images/gamexplain.png";
|
||||
const path = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`;
|
||||
require("util").promisify(fs.writeFile)(path, image.data);
|
||||
const command = gm(template).background("white").out("null:").out("(").out(path).out("-virtual-pixel", "transparent").resize("1181x571!").coalesce().out(")").compose("over").gravity("Center").out("-geometry", "+0+40").out("-layers", "composite");
|
||||
const command = gm(template).background("white").out("null:").out("(").out(path).out("-virtual-pixel", "transparent").resize("1181x571!").coalesce().out(")").compose("over").gravity("Center").out("-geometry", "+0+40").out("-layers", "composite").out("-layers", "optimize");
|
||||
const resultBuffer = await gmToBuffer(command, image.type);
|
||||
return message.channel.createMessage("", {
|
||||
file: resultBuffer,
|
||||
|
|
|
@ -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).out("-repage", `${size.width}x${size.height}`).coalesce().out("null:").out("(").out(data).coalesce().out(")").geometry(`+${size.width / 2}+0`).out("-layers", "Composite");
|
||||
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);
|
||||
return message.channel.createMessage("", {
|
||||
file: resultBuffer,
|
||||
|
|
|
@ -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(data).out("-repage", `${size.width}x${size.height}`).coalesce().out("null:").out("(").out(data2).coalesce().out(")").geometry(`+0+${size.height / 2}`).out("-layers", "Composite");
|
||||
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);
|
||||
return message.channel.createMessage("", {
|
||||
file: resultBuffer,
|
||||
|
|
|
@ -10,7 +10,7 @@ exports.run = async (message) => {
|
|||
const watermark = "./assets/images/hypercam.png";
|
||||
gm(image.data).size(async (error, size) => {
|
||||
if (error) throw error;
|
||||
const data = gm(image.data).coalesce().out("null:").out(watermark).gravity("NorthWest").resize(null, size.height).out("-layers", "composite");
|
||||
const data = gm(image.data).coalesce().out("null:").out(watermark).gravity("NorthWest").resize(null, size.height).out("-layers", "composite").out("-layers", "optimize");
|
||||
const resultBuffer = await gmToBuffer(data);
|
||||
return message.channel.createMessage("", {
|
||||
file: resultBuffer,
|
||||
|
|
|
@ -10,7 +10,7 @@ exports.run = async (message) => {
|
|||
const watermark = "./assets/images/ifunny.png";
|
||||
gm(image.data).size(async (error, size) => {
|
||||
if (error) throw error;
|
||||
const data = gm(image.data).coalesce().out("null:").out(watermark).gravity("South").resize(size.width, null).out("-layers", "composite");
|
||||
const data = gm(image.data).coalesce().out("null:").out(watermark).gravity("South").resize(size.width, null).out("-layers", "composite").out("-layers", "optimize");
|
||||
const resultBuffer = await gmToBuffer(data);
|
||||
return message.channel.createMessage("", {
|
||||
file: resultBuffer,
|
||||
|
|
|
@ -11,7 +11,7 @@ exports.run = async (message) => {
|
|||
let resultBuffer;
|
||||
gm(image.data).size(async (error, size) => {
|
||||
if (error) throw error;
|
||||
const command = gm(image.data).coalesce().background("white").extent(size.width, size.height + 15).out("null:").out(watermark).gravity("SouthEast").compose("over").out("-layers", "composite");
|
||||
const command = gm(image.data).coalesce().background("white").extent(size.width, size.height + 15).out("null:").out(watermark).gravity("SouthEast").compose("over").out("-layers", "composite").out("-layers", "optimize");
|
||||
const output = await gmToBuffer(command, image.type);
|
||||
gm(output).size(async (error, size2) => {
|
||||
if (error) throw error;
|
||||
|
|
|
@ -11,7 +11,7 @@ exports.run = async (message) => {
|
|||
const template = "./assets/images/scott.png";
|
||||
const path = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`;
|
||||
require("util").promisify(fs.writeFile)(path, image.data);
|
||||
const command = gm(template).out("null:").out("(").out(path).out("-virtual-pixel", "transparent").resize("415x234!").coalesce().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 command = gm(template).out("null:").out("(").out(path).out("-virtual-pixel", "transparent").resize("415x234!").coalesce().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 resultBuffer = await gmToBuffer(command, image.type);
|
||||
return message.channel.createMessage("", {
|
||||
file: resultBuffer,
|
||||
|
|
|
@ -10,7 +10,7 @@ exports.run = async (message) => {
|
|||
const watermark = "./assets/images/shutterstock.png";
|
||||
gm(image.data).size(async (error, size) => {
|
||||
if (error) throw error;
|
||||
const command = gm(image.data).coalesce().out("null:").out(watermark).gravity("Center").resize(null, size.height).out("-layers", "composite");
|
||||
const command = gm(image.data).coalesce().out("null:").out(watermark).gravity("Center").resize(null, size.height).out("-layers", "composite").out("-layers", "optimize");
|
||||
const output = await gmToBuffer(command);
|
||||
return message.channel.createMessage("", {
|
||||
file: output,
|
||||
|
|
|
@ -11,7 +11,7 @@ exports.run = async (message) => {
|
|||
const template = "./assets/images/trump.png";
|
||||
const path = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`;
|
||||
require("util").promisify(fs.writeFile)(path, image.data);
|
||||
const command = gm(template).background("white").out("null:").out("(").out(path).out("-virtual-pixel", "transparent").resize("365x179!").coalesce().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 command = gm(template).background("white").out("null:").out("(").out(path).out("-virtual-pixel", "transparent").resize("365x179!").coalesce().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 resultBuffer = await gmToBuffer(command, image.type);
|
||||
return message.channel.createMessage("", {
|
||||
file: resultBuffer,
|
||||
|
|
|
@ -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(data).out("-repage", `${size.width}x${size.height}`).coalesce().out("null:").out("(").out(data2).coalesce().out(")").geometry(`+${size.width / 2}+0`).out("-layers", "Composite");
|
||||
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);
|
||||
return message.channel.createMessage("", {
|
||||
file: resultBuffer,
|
||||
|
|
|
@ -11,7 +11,7 @@ exports.run = async (message) => {
|
|||
const template = "./assets/images/whodidthis.png";
|
||||
const path = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`;
|
||||
require("util").promisify(fs.writeFile)(path, image.data);
|
||||
const command = gm(template).coalesce().out("null:").out(path).gravity("Center").resize("374x374>").out("-layers", "composite");
|
||||
const command = gm(template).coalesce().out("null:").out(path).gravity("Center").resize("374x374>").out("-layers", "composite").out("-layers", "optimize");
|
||||
const resultBuffer = await gmToBuffer(command, image.type);
|
||||
return message.channel.createMessage("", {
|
||||
file: resultBuffer,
|
||||
|
|
|
@ -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).out("-repage", `${size.width}x${size.height}`).coalesce().out("null:").out("(").out(data).coalesce().out(")").geometry(`+0+${size.height / 2}`).out("-layers", "Composite");
|
||||
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);
|
||||
return message.channel.createMessage("", {
|
||||
file: resultBuffer,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue