Removed extra image request for image commands, various other tweaks
This commit is contained in:
parent
4439fca6d3
commit
ef071a39d4
39 changed files with 67 additions and 156 deletions
|
@ -2,16 +2,13 @@ const gm = require("gm").subClass({
|
|||
imageMagick: true
|
||||
});
|
||||
const gmToBuffer = require("../utils/gmbuffer.js");
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
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!`;
|
||||
message.channel.sendTyping();
|
||||
const watermark = "./assets/images/9gag.png";
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
const data = gm(imageBuffer).composite(watermark).gravity("East");
|
||||
const data = gm(image.data).composite(watermark).gravity("East");
|
||||
const resultBuffer = await gmToBuffer(data);
|
||||
return message.channel.createMessage("", {
|
||||
file: resultBuffer,
|
||||
|
|
|
@ -2,18 +2,15 @@ const gm = require("gm").subClass({
|
|||
imageMagick: true
|
||||
});
|
||||
const gmToBuffer = require("../utils/gmbuffer.js");
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
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 Bandicam watermark!`;
|
||||
message.channel.sendTyping();
|
||||
const watermark = "./assets/images/bandicam.png";
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
gm(imageBuffer).size(async (error, size) => {
|
||||
gm(image.data).size(async (error, size) => {
|
||||
if (error) console.error;
|
||||
const data = gm(imageBuffer).composite(watermark).gravity("North").resize(null, size.height);
|
||||
const data = gm(image.data).composite(watermark).gravity("North").resize(null, size.height);
|
||||
const resultBuffer = await gmToBuffer(data);
|
||||
return message.channel.createMessage("", {
|
||||
file: resultBuffer,
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
const sharp = require("sharp");
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
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 blur!`;
|
||||
message.channel.sendTyping();
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
const resultBuffer = await sharp(imageBuffer).blur(5).toBuffer();
|
||||
const resultBuffer = await sharp(image.data).blur(5).toBuffer();
|
||||
return message.channel.createMessage("", {
|
||||
file: resultBuffer,
|
||||
name: `blur.${image.type}`
|
||||
|
|
|
@ -2,15 +2,12 @@ const gm = require("gm").subClass({
|
|||
imageMagick: true
|
||||
});
|
||||
const gmToBuffer = require("../utils/gmbuffer.js");
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
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 blurple!`;
|
||||
message.channel.sendTyping();
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
const data = gm(imageBuffer).threshold(75, true).out("+level-colors").out("\"#7289DA\",white");
|
||||
const data = gm(image.data).threshold(75, true).out("+level-colors").out("\"#7289DA\",white");
|
||||
const resultBuffer = await gmToBuffer(data);
|
||||
return message.channel.createMessage("", {
|
||||
file: resultBuffer,
|
||||
|
|
|
@ -2,15 +2,12 @@ const gm = require("gm").subClass({
|
|||
imageMagick: true
|
||||
});
|
||||
const gmToBuffer = require("../utils/gmbuffer.js");
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
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 radial blur!`;
|
||||
message.channel.sendTyping();
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
const data = gm(imageBuffer).out("-radial-blur", 10);
|
||||
const data = gm(image.data).out("-radial-blur", 10);
|
||||
const resultBuffer = await gmToBuffer(data);
|
||||
return message.channel.createMessage("", {
|
||||
file: resultBuffer,
|
||||
|
|
|
@ -2,18 +2,15 @@ const gm = require("gm").subClass({
|
|||
imageMagick: true
|
||||
});
|
||||
const gmToBuffer = require("../utils/gmbuffer.js");
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
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 DeviantArt watermark!`;
|
||||
message.channel.sendTyping();
|
||||
const watermark = "./assets/images/deviantart.png";
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
gm(imageBuffer).size(async (error, size) => {
|
||||
gm(image.data).size(async (error, size) => {
|
||||
if (error) console.error;
|
||||
const data = gm(imageBuffer).composite(watermark).gravity("Center").resize(null, size.height);
|
||||
const data = gm(image.data).composite(watermark).gravity("Center").resize(null, size.height);
|
||||
const resultBuffer = await gmToBuffer(data);
|
||||
return message.channel.createMessage("", {
|
||||
file: resultBuffer,
|
||||
|
|
|
@ -2,15 +2,12 @@ const gm = require("gm").subClass({
|
|||
imageMagick: true
|
||||
});
|
||||
const gmToBuffer = require("../utils/gmbuffer.js");
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
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 explode!`;
|
||||
message.channel.sendTyping();
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
const data = gm(imageBuffer).implode([-2]);
|
||||
const data = gm(image.data).implode([-2]);
|
||||
const resultBuffer = await gmToBuffer(data);
|
||||
return message.channel.createMessage("", {
|
||||
file: resultBuffer,
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
const sharp = require("sharp");
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
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 flip!`;
|
||||
message.channel.sendTyping();
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
const resultBuffer = await sharp(imageBuffer).flip().toBuffer();
|
||||
const resultBuffer = await sharp(image.data).flip().toBuffer();
|
||||
return message.channel.createMessage("", {
|
||||
file: resultBuffer,
|
||||
name: `flip.${image.type}`
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
const sharp = require("sharp");
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
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 flop!`;
|
||||
message.channel.sendTyping();
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
const resultBuffer = await sharp(imageBuffer).flop().toBuffer();
|
||||
const resultBuffer = await sharp(image.data).flop().toBuffer();
|
||||
return message.channel.createMessage("", {
|
||||
file: resultBuffer,
|
||||
name: `flop.${image.type}`
|
||||
|
|
|
@ -2,18 +2,15 @@ const gm = require("gm").subClass({
|
|||
imageMagick: true
|
||||
});
|
||||
const gmToBuffer = require("../utils/gmbuffer.js");
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
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 New Funky Mode!`;
|
||||
message.channel.sendTyping();
|
||||
const watermark = "./assets/images/funky.png";
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
gm(imageBuffer).size(async (error, size) => {
|
||||
gm(image.data).size(async (error, size) => {
|
||||
if (error) console.error;
|
||||
const data = gm(imageBuffer).composite(watermark).gravity("NorthEast").resize(null, size.height);
|
||||
const data = gm(image.data).composite(watermark).gravity("NorthEast").resize(null, size.height);
|
||||
const resultBuffer = await gmToBuffer(data);
|
||||
return message.channel.createMessage("", {
|
||||
file: resultBuffer,
|
||||
|
|
|
@ -2,7 +2,6 @@ const gm = require("gm").subClass({
|
|||
imageMagick: true
|
||||
});
|
||||
const gmToBuffer = require("../utils/gmbuffer.js");
|
||||
const fetch = require("node-fetch");
|
||||
const fs = require("fs");
|
||||
|
||||
exports.run = async (message) => {
|
||||
|
@ -10,10 +9,8 @@ exports.run = async (message) => {
|
|||
if (image === undefined) return `${message.author.mention}, you need to provide an image to make a GameXplain thumbnail meme!`;
|
||||
message.channel.sendTyping();
|
||||
const template = "./assets/images/gamexplain.png";
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
const path = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`;
|
||||
require("util").promisify(fs.writeFile)(path, imageBuffer);
|
||||
require("util").promisify(fs.writeFile)(path, image.data);
|
||||
const command = gm(template).out("-background").out("white").out("-gravity").out("Center").out("(").out("-clone").out("0").out("(").out(path).out("-virtual-pixel").out("transparent").out("-resize").out("1181x571!").out(")").out("-geometry").out("+0+40").out("-composite").out(")").out("+swap").out("-composite");
|
||||
const resultBuffer = await gmToBuffer(command);
|
||||
return message.channel.createMessage("", {
|
||||
|
|
|
@ -3,17 +3,14 @@
|
|||
const gm = require("gm").subClass({
|
||||
imageMagick: true
|
||||
});
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
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 mirror!`;
|
||||
message.channel.sendTyping();
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
const data = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`;
|
||||
const data2 = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`;
|
||||
gm(imageBuffer).gravity("West").crop("50%", 0).strip().write(data2, (error) => {
|
||||
gm(image.data).gravity("West").crop("50%", 0).strip().write(data2, (error) => {
|
||||
if (error) console.error;
|
||||
gm(data2).flop().strip().write(data, async (error) => {
|
||||
if (error) console.error;
|
||||
|
|
|
@ -3,17 +3,14 @@
|
|||
const gm = require("gm").subClass({
|
||||
imageMagick: true
|
||||
});
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
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 mirror!`;
|
||||
message.channel.sendTyping();
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
const data = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`;
|
||||
const data2 = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`;
|
||||
gm(imageBuffer).gravity("South").crop(0, "50%").strip().write(data2, (error) => {
|
||||
gm(image.data).gravity("South").crop(0, "50%").strip().write(data2, (error) => {
|
||||
if (error) console.error;
|
||||
gm(data2).flip().strip().write(data, async (error) => {
|
||||
if (error) console.error;
|
||||
|
|
|
@ -2,18 +2,15 @@ const gm = require("gm").subClass({
|
|||
imageMagick: true
|
||||
});
|
||||
const gmToBuffer = require("../utils/gmbuffer.js");
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
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 Hypercam watermark!`;
|
||||
message.channel.sendTyping();
|
||||
const watermark = "./assets/images/hypercam.png";
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
gm(imageBuffer).size(async (error, size) => {
|
||||
gm(image.data).size(async (error, size) => {
|
||||
if (error) console.error;
|
||||
const data = gm(imageBuffer).composite(watermark).gravity("NorthWest").resize(null, size.height);
|
||||
const data = gm(image.data).composite(watermark).gravity("NorthWest").resize(null, size.height);
|
||||
const resultBuffer = await gmToBuffer(data);
|
||||
return message.channel.createMessage("", {
|
||||
file: resultBuffer,
|
||||
|
|
|
@ -2,18 +2,15 @@ const gm = require("gm").subClass({
|
|||
imageMagick: true
|
||||
});
|
||||
const gmToBuffer = require("../utils/gmbuffer.js");
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
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 iFunny watermark!`;
|
||||
message.channel.sendTyping();
|
||||
const watermark = "./assets/images/ifunny.png";
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
gm(imageBuffer).size(async (error, size) => {
|
||||
gm(image.data).size(async (error, size) => {
|
||||
if (error) console.error;
|
||||
const data = gm(imageBuffer).append(watermark).gravity("South").resize(size.width, null);
|
||||
const data = gm(image.data).append(watermark).gravity("South").resize(size.width, null);
|
||||
const resultBuffer = await gmToBuffer(data);
|
||||
return message.channel.createMessage("", {
|
||||
file: resultBuffer,
|
||||
|
|
|
@ -2,15 +2,12 @@ const gm = require("gm").subClass({
|
|||
imageMagick: true
|
||||
});
|
||||
const gmToBuffer = require("../utils/gmbuffer.js");
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
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 implode!`;
|
||||
message.channel.sendTyping();
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
const data = gm(imageBuffer).implode([1]);
|
||||
const data = gm(image.data).implode([1]);
|
||||
const resultBuffer = await gmToBuffer(data);
|
||||
return message.channel.createMessage("", {
|
||||
file: resultBuffer,
|
||||
|
|
|
@ -2,15 +2,12 @@ const gm = require("gm").subClass({
|
|||
imageMagick: true
|
||||
});
|
||||
const gmToBuffer = require("../utils/gmbuffer.js");
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
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 invert!`;
|
||||
message.channel.sendTyping();
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
const data = gm(imageBuffer).negative();
|
||||
const data = gm(image.data).negative();
|
||||
const resultBuffer = await gmToBuffer(data);
|
||||
return message.channel.createMessage("", {
|
||||
file: resultBuffer,
|
||||
|
|
|
@ -2,15 +2,12 @@ const gm = require("gm").subClass({
|
|||
imageMagick: true
|
||||
});
|
||||
const gmToBuffer = require("../utils/gmbuffer.js");
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
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 more JPEG!`;
|
||||
message.channel.sendTyping();
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
const data = gm(imageBuffer).setFormat("jpg").quality(1);
|
||||
const data = gm(image.data).setFormat("jpg").quality(1);
|
||||
const resultBuffer = await gmToBuffer(data);
|
||||
return message.channel.createMessage("", {
|
||||
file: resultBuffer,
|
||||
|
|
|
@ -2,15 +2,12 @@ const gm = require("gm").subClass({
|
|||
imageMagick: true
|
||||
});
|
||||
const gmToBuffer = require("../utils/gmbuffer.js");
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
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 some magik!`;
|
||||
const processMessage = await message.channel.createMessage("<a:processing:479351417102925854> Processing... This might take a while");
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
gm(imageBuffer).resize(800, 800).stream((error, stream) => {
|
||||
gm(image.data).resize(800, 800).stream((error, stream) => {
|
||||
if (error) console.error;
|
||||
gm(stream).out("-liquid-rescale", "400x400").stream(async (error, stream2) => {
|
||||
if (error) console.error;
|
||||
|
|
|
@ -1,16 +1,13 @@
|
|||
const { spawn } = require("child_process");
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
exports.run = async (message, args) => {
|
||||
const image = await require("../utils/imagedetect.js")(message);
|
||||
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!`;
|
||||
message.channel.sendTyping();
|
||||
const request = await fetch(image.url);
|
||||
const buffer = await request.buffer();
|
||||
const [topText, bottomText] = args.join(" ").split(",").map(elem => elem.trim());
|
||||
const child = spawn("./utils/meme.sh", [topText.toUpperCase().replace(/\\/g, "\\\\"), bottomText ? bottomText.toUpperCase().replace(/\\/g, "\\\\") : ""]);
|
||||
child.stdin.write(buffer);
|
||||
child.stdin.write(image.data);
|
||||
child.stdin.end();
|
||||
const chunks = [];
|
||||
child.stdout.on("data", (data) => {
|
||||
|
|
|
@ -2,20 +2,17 @@ const gm = require("gm").subClass({
|
|||
imageMagick: true
|
||||
});
|
||||
const gmToBuffer = require("../utils/gmbuffer.js");
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
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 MemeCenter watermark!`;
|
||||
message.channel.sendTyping();
|
||||
const watermark = "./assets/images/memecenter.png";
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
let resultBuffer;
|
||||
gm(imageBuffer).size(async (error, size) => {
|
||||
gm(image.data).size(async (error, size) => {
|
||||
if (error) console.error;
|
||||
const command = gm(imageBuffer).out(watermark).background("#FFFFFF").gravity("East").out("-smush").out("-9");
|
||||
const output = await gmToBuffer(command);
|
||||
const command = gm(image.data).out(watermark).background("#FFFFFF").gravity("East").out("-smush").out("-9");
|
||||
const output = await gmToBuffer(command, "png");
|
||||
gm(output).size(async (error, size2) => {
|
||||
if (error) console.error;
|
||||
resultBuffer = output;
|
||||
|
@ -25,7 +22,7 @@ exports.run = async (message) => {
|
|||
}
|
||||
return message.channel.createMessage("", {
|
||||
file: resultBuffer,
|
||||
name: "memecenter.png"
|
||||
name: `memecenter.${image.type}`
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -11,9 +11,9 @@ exports.run = async (message) => {
|
|||
inlineVolume: true
|
||||
});
|
||||
connection.setVolume(0.5);
|
||||
connection.on("error", () => {
|
||||
connection.on("error", (error) => {
|
||||
voiceChannel.leave();
|
||||
console.error;
|
||||
throw error;
|
||||
});
|
||||
connection.on("end", () => {
|
||||
voiceChannel.leave();
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
const fetch = require("node-fetch");
|
||||
const jsqr = require("jsqr");
|
||||
const sharp = require("sharp");
|
||||
|
||||
|
@ -6,9 +5,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 with a QR code to read it!`;
|
||||
message.channel.sendTyping();
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
const rawData = await sharp(imageBuffer).ensureAlpha().raw().toBuffer({ resolveWithObject: true });
|
||||
const rawData = await sharp(image.data).ensureAlpha().raw().toBuffer({ resolveWithObject: true });
|
||||
const qrBuffer = jsqr(rawData.data, rawData.info.width, rawData.info.height);
|
||||
return `\`\`\`\n${qrBuffer.data}\n\`\`\``;
|
||||
};
|
|
@ -2,7 +2,6 @@ const gm = require("gm").subClass({
|
|||
imageMagick: true
|
||||
});
|
||||
const gmToBuffer = require("../utils/gmbuffer.js");
|
||||
const fetch = require("node-fetch");
|
||||
const fs = require("fs");
|
||||
|
||||
exports.run = async (message) => {
|
||||
|
@ -10,12 +9,10 @@ exports.run = async (message) => {
|
|||
if (image === undefined) return `${message.author.mention}, you need to provide an image to make a Scott the Woz TV meme!`;
|
||||
message.channel.sendTyping();
|
||||
const template = "./assets/images/scott.png";
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
const path = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`;
|
||||
require("util").promisify(fs.writeFile)(path, imageBuffer);
|
||||
require("util").promisify(fs.writeFile)(path, image.data);
|
||||
const command = gm(template).out("-gravity").out("Center").out("(").out(path).out("-virtual-pixel").out("transparent").out("-resize").out("415x234!").out("+distort").out("Perspective").out("0,0 129,187 415,0 517,182 415,234 517,465 0,234 132,418").out("-geometry").out("-110+83").out(")").out("-composite");
|
||||
const resultBuffer = await gmToBuffer(command);
|
||||
const resultBuffer = await gmToBuffer(command, "png");
|
||||
return message.channel.createMessage("", {
|
||||
file: resultBuffer,
|
||||
name: "scott.png"
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
const sharp = require("sharp");
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
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 sharpen!`;
|
||||
message.channel.sendTyping();
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
const resultBuffer = await sharp(imageBuffer).sharpen(5).toBuffer();
|
||||
const resultBuffer = await sharp(image.data).sharpen(5).toBuffer();
|
||||
return message.channel.createMessage("", {
|
||||
file: resultBuffer,
|
||||
name: "sharpen.png"
|
||||
|
|
|
@ -2,22 +2,19 @@ const gm = require("gm").subClass({
|
|||
imageMagick: true
|
||||
});
|
||||
const gmToBuffer = require("../utils/gmbuffer.js");
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
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 Shutterstock watermark!`;
|
||||
message.channel.sendTyping();
|
||||
const watermark = "./assets/images/shutterstock.png";
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
gm(imageBuffer).size(async (error, size) => {
|
||||
gm(image.data).size(async (error, size) => {
|
||||
if (error) console.error;
|
||||
const command = gm(imageBuffer).composite(watermark).gravity("Center").resize(null, size.height);
|
||||
const command = gm(image.data).composite(watermark).gravity("Center").resize(null, size.height);
|
||||
const output = await gmToBuffer(command);
|
||||
return message.channel.createMessage("", {
|
||||
file: output,
|
||||
name: "shutterstock.png"
|
||||
name: `shutterstock.${image.type}`
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
@ -13,7 +13,7 @@ exports.run = async (message, args) => {
|
|||
gm(474, 332).out("+size").gravity("Center").out("-pointsize", 40).out("-font", "Bitstream Vera Sans").out(`pango:${wrap(cleanedMessage, {width: 15, indent: ""})}`).negative().out("-fuzz", "30%").transparent("black").write(file, async (error) => {
|
||||
if (error) console.error;
|
||||
const command = gm(template).composite(file).gravity("Center").geometry("474x332+160+10");
|
||||
const resultBuffer = await gmToBuffer(command);
|
||||
const resultBuffer = await gmToBuffer(command, "png");
|
||||
return message.channel.createMessage("", {
|
||||
file: resultBuffer,
|
||||
name: "sonic.png"
|
||||
|
|
|
@ -2,15 +2,12 @@ const gm = require("gm").subClass({
|
|||
imageMagick: true
|
||||
});
|
||||
const gmToBuffer = require("../utils/gmbuffer.js");
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
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 swirl!`;
|
||||
message.channel.sendTyping();
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
const data = gm(imageBuffer).swirl(180);
|
||||
const data = gm(image.data).swirl(180);
|
||||
const resultBuffer = await gmToBuffer(data);
|
||||
return message.channel.createMessage("", {
|
||||
file: resultBuffer,
|
||||
|
|
|
@ -2,15 +2,12 @@ const gm = require("gm").subClass({
|
|||
imageMagick: true
|
||||
});
|
||||
const gmToBuffer = require("../utils/gmbuffer.js");
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
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 tile!`;
|
||||
message.channel.sendTyping();
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
gm(imageBuffer).command("montage").out("-duplicate").out(24).tile("5x5").geometry("+0+0").stream(async (error, output) => {
|
||||
gm(image.data).command("montage").out("-duplicate").out(24).tile("5x5").geometry("+0+0").stream(async (error, output) => {
|
||||
if (error) console.error;
|
||||
const data = gm(output).resize("800x800>");
|
||||
const resultBuffer = await gmToBuffer(data);
|
||||
|
|
|
@ -2,7 +2,6 @@ const gm = require("gm").subClass({
|
|||
imageMagick: true
|
||||
});
|
||||
const gmToBuffer = require("../utils/gmbuffer.js");
|
||||
const fetch = require("node-fetch");
|
||||
const fs = require("fs");
|
||||
|
||||
exports.run = async (message) => {
|
||||
|
@ -10,12 +9,10 @@ exports.run = async (message) => {
|
|||
if (image === undefined) return `${message.author.mention}, you need to provide an image to make a Trump meme!`;
|
||||
message.channel.sendTyping();
|
||||
const template = "./assets/images/trump.png";
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
const path = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`;
|
||||
require("util").promisify(fs.writeFile)(path, imageBuffer);
|
||||
require("util").promisify(fs.writeFile)(path, image.data);
|
||||
const command = gm(template).out("-background").out("none").out("-gravity").out("South").out("(").out("-clone").out("0").out("(").out(path).out("-virtual-pixel").out("transparent").out("-resize").out("365x179!").out("+distort").out("Perspective").out("0,0 207,268 365,0 548,271 365,179 558,450 0,179 193,450").out(")").out("-geometry").out("-25-1").out("-composite").out(")").out("+swap").out("-composite");
|
||||
const resultBuffer = await gmToBuffer(command);
|
||||
const resultBuffer = await gmToBuffer(command, "png");
|
||||
return message.channel.createMessage("", {
|
||||
file: resultBuffer,
|
||||
name: "trump.png"
|
||||
|
|
|
@ -3,17 +3,14 @@
|
|||
const gm = require("gm").subClass({
|
||||
imageMagick: true
|
||||
});
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
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 mirror!`;
|
||||
message.channel.sendTyping();
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
const data = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`;
|
||||
const data2 = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`;
|
||||
gm(imageBuffer).gravity("East").crop("50%", 0).strip().write(data2, (error) => {
|
||||
gm(image.data).gravity("East").crop("50%", 0).strip().write(data2, (error) => {
|
||||
if (error) console.error;
|
||||
gm(data2).flop().strip().write(data, async (error) => {
|
||||
if (error) console.error;
|
||||
|
|
|
@ -2,15 +2,12 @@ const gm = require("gm").subClass({
|
|||
imageMagick: true
|
||||
});
|
||||
const gmToBuffer = require("../utils/gmbuffer.js");
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
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 wall from!`;
|
||||
message.channel.sendTyping();
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
gm(imageBuffer).resize(128).stream(async (error, output) => {
|
||||
gm(image.data).resize(128).stream(async (error, output) => {
|
||||
if (error) console.error;
|
||||
const data = gm(output).virtualPixel("tile").matteColor("none").out("-background", "none").resize("512x512!").out("-distort").out("Perspective").out("0,0,57,42 0,128,63,130 128,0,140,60 128,128,140,140");
|
||||
const resultBuffer = await gmToBuffer(data);
|
||||
|
|
|
@ -2,7 +2,6 @@ const gm = require("gm").subClass({
|
|||
imageMagick: true
|
||||
});
|
||||
const gmToBuffer = require("../utils/gmbuffer.js");
|
||||
const fetch = require("node-fetch");
|
||||
const fs = require("fs");
|
||||
|
||||
exports.run = async (message) => {
|
||||
|
@ -10,12 +9,10 @@ exports.run = async (message) => {
|
|||
if (image === undefined) return `${message.author.mention}, you need to provide an image to make a "who did this" meme!`;
|
||||
message.channel.sendTyping();
|
||||
const template = "./assets/images/whodidthis.png";
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
const path = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`;
|
||||
require("util").promisify(fs.writeFile)(path, imageBuffer);
|
||||
require("util").promisify(fs.writeFile)(path, image.data);
|
||||
const command = gm(template).composite(path).gravity("Center").geometry("374x374+0+0");
|
||||
const resultBuffer = await gmToBuffer(command);
|
||||
const resultBuffer = await gmToBuffer(command, "png");
|
||||
return message.channel.createMessage("", {
|
||||
file: resultBuffer,
|
||||
name: "wdt.png"
|
||||
|
|
|
@ -3,17 +3,14 @@
|
|||
const gm = require("gm").subClass({
|
||||
imageMagick: true
|
||||
});
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
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 mirror!`;
|
||||
message.channel.sendTyping();
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
const data = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`;
|
||||
const data2 = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`;
|
||||
gm(imageBuffer).gravity("North").crop(0, "50%").strip().write(data2, (error) => {
|
||||
gm(image.data).gravity("North").crop(0, "50%").strip().write(data2, (error) => {
|
||||
if (error) console.error;
|
||||
gm(data2).flip().strip().write(data, async (error) => {
|
||||
if (error) console.error;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue