Upgraded to ImageMagick 7, modified many commands to use fx operators instead of identify
This commit is contained in:
parent
0ff784089b
commit
b4c8d243a8
22 changed files with 29 additions and 47 deletions
|
@ -7,8 +7,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 Bandicam watermark!`;
|
||||
const watermark = "./assets/images/bandicam.png";
|
||||
const size = await gm(image.path).sizePromise();
|
||||
const buffer = await gm(image.path).coalesce().out("null:").out(watermark).gravity("North").resize(null, size.height).out("-layers", "composite").bufferPromise(image.type);
|
||||
const buffer = await gm(image.path).coalesce().out("null:").out(watermark).gravity("North").resize(null, "%[fx:u.h]").out("-layers", "composite").bufferPromise(image.type);
|
||||
return message.channel.createMessage("", {
|
||||
file: buffer,
|
||||
name: `bandicam.${image.type}`
|
||||
|
|
|
@ -6,7 +6,7 @@ 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 blur!`;
|
||||
const buffer = await gm(image.path).blur(15).bufferPromise(image.type);
|
||||
const buffer = await gm(image.path).coalesce().blur(15).bufferPromise(image.type);
|
||||
return message.channel.createMessage("", {
|
||||
file: buffer,
|
||||
name: `blur.${image.type}`
|
||||
|
|
|
@ -6,7 +6,7 @@ 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 make blurple!`;
|
||||
const buffer = await gm(image.path).threshold(75, true).out("+level-colors").out("\"#7289DA\",white").bufferPromise(image.type);
|
||||
const buffer = await gm(image.path).coalesce().threshold(75, true).out("+level-colors").out("\"#7289DA\",white").bufferPromise(image.type);
|
||||
return message.channel.createMessage("", {
|
||||
file: buffer,
|
||||
name: `blurple.${image.type}`
|
||||
|
|
|
@ -8,10 +8,8 @@ exports.run = async (message, args) => {
|
|||
if (image === undefined) return `${message.author.mention}, you need to provide an image/GIF to add a caption!`;
|
||||
if (args.length === 0) return `${message.author.mention}, you need to provide some text to add a caption!`;
|
||||
const processMessage = await message.channel.createMessage("<a:processing:479351417102925854> Processing... This might take a while");
|
||||
const size = await gm(image.path).sizePromise();
|
||||
const output = await gm().out("-size", `${size.width}x`).background("white").fill("black").font("./assets/caption.otf", size.width / 10).gravity("Center").out(`caption:${args.join(" ")}`).bufferPromise("png");
|
||||
const size2 = await gm(output).sizePromise();
|
||||
const output2 = await gm(output).gravity("Center").trim().out("+repage").extent(size.width, size2.height + (size.width / 10)).streamPromise();
|
||||
const output = await gm(image.path).out("-size", "%[fx:w]x").background("white").fill("black").font("./assets/caption.otf", "%[fx:w/10]").out("-delete", "0--1").gravity("Center").out(`caption:${args.join(" ")}`).bufferPromise("png");
|
||||
const output2 = await gm(output).out(image.path).gravity("Center").trim().out("+repage").extent("%[fx:v.w]", "%[fx:u.h + ( v.w/10 )]").out("-delete", "1--1").streamPromise();
|
||||
const outputFinal = await 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").bufferPromise(image.type);
|
||||
await processMessage.delete();
|
||||
//return upload(message, outputFinal, `caption.${image.type}`);
|
||||
|
|
|
@ -6,7 +6,7 @@ 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 add radial blur!`;
|
||||
const buffer = await gm(image.path).coalesce().out("-radial-blur", 10).bufferPromise(image.type);
|
||||
const buffer = await gm(image.path).coalesce().out("-rotational-blur", 10).bufferPromise(image.type);
|
||||
return message.channel.createMessage("", {
|
||||
file: buffer,
|
||||
name: `circle.${image.type}`
|
||||
|
|
|
@ -7,8 +7,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 DeviantArt watermark!`;
|
||||
const watermark = "./assets/images/deviantart.png";
|
||||
const size = await gm(image.path).sizePromise();
|
||||
const buffer = await gm(image.path).coalesce().out("null:").out(watermark).gravity("Center").resize(null, size.height).out("-layers", "composite").bufferPromise(image.type);
|
||||
const buffer = await gm(image.path).coalesce().out("null:").out(watermark).gravity("Center").resize(null, "%[fx:u.h]").out("-layers", "composite").bufferPromise(image.type);
|
||||
return message.channel.createMessage("", {
|
||||
file: buffer,
|
||||
name: `deviantart.${image.type}`
|
||||
|
|
|
@ -7,8 +7,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 New Funky Mode!`;
|
||||
const watermark = "./assets/images/funky.png";
|
||||
const size = await gm(image.path).sizePromise();
|
||||
const buffer = await gm(image.path).coalesce().out("null:").out(watermark).gravity("NorthEast").resize(null, size.height).out("-layers", "composite").bufferPromise(image.type);
|
||||
const buffer = await gm(image.path).coalesce().out("null:").out(watermark).gravity("NorthEast").resize(null, "%[fx:u.h]").out("-layers", "composite").bufferPromise(image.type);
|
||||
return message.channel.createMessage("", {
|
||||
file: buffer,
|
||||
name: `funky.${image.type}`
|
||||
|
|
|
@ -8,10 +8,9 @@ exports.run = async (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)}.miff`;
|
||||
const data2 = `/tmp/${Math.random().toString(36).substring(2, 15)}.miff`;
|
||||
const size = await gm(image.path).sizePromise();
|
||||
await gm(image.path).coalesce().gravity("West").crop("50%", 0).out("+repage").writePromise(data2);
|
||||
await gm(data2).flop().writePromise(data);
|
||||
const buffer = await gm(data2).extent(size.width, size.height).out("null:").out(data).geometry(`+${size.width / 2}+0`).out("-layers", "Composite").bufferPromise(image.type);
|
||||
const buffer = await gm(data2).extent("%[fx:u.w*2]", "%[fx:u.h]").out("null:").out(data).gravity("East").out("-layers", "Composite").bufferPromise(image.type);
|
||||
return message.channel.createMessage("", {
|
||||
file: buffer,
|
||||
name: `haah.${image.type}`
|
||||
|
|
|
@ -11,6 +11,7 @@ exports.run = async (message) => {
|
|||
const size = await gm(image.path).sizePromise();
|
||||
await gm(image.path).coalesce().gravity("South").crop(0, "50%").out("+repage").writePromise(data2);
|
||||
await gm(data2).flip().writePromise(data);
|
||||
// const buffer = await gm(data2).extent("%[fx:u.w]", "%[fx:u.h*2]").out("null:").out(data).gravity("North").out("-layers", "Composite").bufferPromise(image.type);
|
||||
const buffer = await gm(data2).extent(size.width, size.height).out("null:").out(data).geometry(`+0+${size.height / 2}`).out("-layers", "Composite").bufferPromise(image.type);
|
||||
return message.channel.createMessage("", {
|
||||
file: buffer,
|
||||
|
|
|
@ -7,8 +7,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 Hypercam watermark!`;
|
||||
const watermark = "./assets/images/hypercam.png";
|
||||
const size = await gm(image.path).sizePromise();
|
||||
const buffer = await gm(image.path).coalesce().out("null:").out(watermark).gravity("NorthWest").resize(null, size.height).out("-layers", "composite").bufferPromse(image.type);
|
||||
const buffer = await gm(image.path).coalesce().out("null:").out(watermark).gravity("NorthWest").resize(null, "%[fx:u.h]").out("-layers", "composite").bufferPromise(image.type);
|
||||
return message.channel.createMessage("", {
|
||||
file: buffer,
|
||||
name: `hypercam.${image.type}`
|
||||
|
|
|
@ -7,8 +7,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 iFunny watermark!`;
|
||||
const watermark = "./assets/images/ifunny.png";
|
||||
const size = await gm(image.path).sizePromise();
|
||||
const buffer = await gm(image.path).coalesce().extent(size.width, size.height + (42 * Math.min(size.width / 1024, size.height / 42))).out("null:").out(watermark).gravity("South").resize(size.width, null).out("-layers", "composite").bufferPromise(image.type);
|
||||
const buffer = await gm(image.path).coalesce().extent("%[fx:u.w]", "%[fx:u.h+(42*min(u.w/1024,u.h/42))]").out("null:").out(watermark).gravity("South").resize("%[fx:u.w]", null).out("-layers", "composite").bufferPromise(image.type);
|
||||
return message.channel.createMessage("", {
|
||||
file: buffer,
|
||||
name: `ifunny.${image.type}`
|
||||
|
|
|
@ -6,7 +6,7 @@ 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 invert!`;
|
||||
const buffer = await gm(image.path).negative().bufferPromise(image.type);
|
||||
const buffer = await gm(image.path).coalesce().negative().bufferPromise(image.type);
|
||||
return message.channel.createMessage("", {
|
||||
file: buffer,
|
||||
name: `invert.${image.type}`
|
||||
|
|
|
@ -12,9 +12,8 @@ exports.run = async (message, args) => {
|
|||
const file2 = `/tmp/${Math.random().toString(36).substring(2, 15)}.png`;
|
||||
const file3 = `/tmp/${Math.random().toString(36).substring(2, 15)}.png`;
|
||||
await gm(image.path).coalesce().resize(600, 600).noProfile().writePromise(file);
|
||||
const size = await gm(file).sizePromise();
|
||||
await gm().out("-size", size.width).background("none").gravity("Center").out("(", "(").font("Impact").out("-pointsize", 40).out(`pango:<span foreground='white'>${topText.toUpperCase().replace(/&/g, "\\&").replace(/>/g, "\\>").replace(/</g, "\\<").replace(/"/g, "\\"").replace(/'/g, "\\'")}</span>`).out(")", "(", "+clone").out("-channel", "A").out("-morphology", "EdgeOut", "Octagon", "+channel", "+level-colors", "black", ")").compose("DstOver").out(")", "-composite").writePromise(file2);
|
||||
if (bottomText) await gm().out("-size", size.width).background("none").gravity("Center").out("(", "(").font("Impact").out("-pointsize", 40).out(`pango:<span foreground='white'>${bottomText.toUpperCase().replace(/&/g, "\\&").replace(/>/g, "\\>").replace(/</g, "\\<").replace(/"/g, "\\"").replace(/'/g, "\\'")}</span>`).out(")", "(", "+clone").out("-channel", "A").out("-morphology", "EdgeOut", "Octagon", "+channel", "+level-colors", "black", ")").compose("DstOver").out(")", "-composite").writePromise(file3);
|
||||
await gm(file).out("-size", "%[fx:u.w]").out("-delete", "0--1").background("none").gravity("Center").out("(", "(").font("Impact").out("-pointsize", 40).out(`pango:<span foreground='white'>${topText.toUpperCase().replace(/&/g, "\\&").replace(/>/g, "\\>").replace(/</g, "\\<").replace(/"/g, "\\"").replace(/'/g, "\\'")}</span>`).out(")", "(", "+clone").out("-alpha", "extract").out("-morphology", "EdgeOut", "Octagon", "-background", "black", "-alpha", "shape", ")").compose("DstOver").out(")", "-composite").writePromise(file2);
|
||||
if (bottomText) await gm(file).out("-size", "%[fx:u.w]").out("-delete", "0--1").background("none").gravity("Center").out("(", "(").font("Impact").out("-pointsize", 40).out(`pango:<span foreground='white'>${bottomText.toUpperCase().replace(/&/g, "\\&").replace(/>/g, "\\>").replace(/</g, "\\<").replace(/"/g, "\\"").replace(/'/g, "\\'")}</span>`).out(")", "(", "+clone").out("-alpha", "extract").out("-morphology", "EdgeOut", "Octagon", "-background", "black", "-alpha", "shape", ")").compose("DstOver").out(")", "-composite").writePromise(file3);
|
||||
const buffer = await gm(file).out("-coalesce").out("null:").gravity("North").out(file2).out("-layers", "composite").out("null:").gravity("South").out(bottomText ? file3 : "null:").out("-layers", "composite").bufferPromise(image.type);
|
||||
return message.channel.createMessage("", {
|
||||
file: buffer,
|
||||
|
|
|
@ -7,16 +7,9 @@ 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!`;
|
||||
const watermark = "./assets/images/memecenter.png";
|
||||
let resultBuffer;
|
||||
const size = await gm(image.path).sizePromise();
|
||||
const output = await gm(image.path).coalesce().background("white").extent(size.width, size.height + 15).out("null:").out(watermark).gravity("SouthEast").compose("over").out("-layers", "composite").bufferPromise(image.type);
|
||||
const size2 = await gm(output).sizePromise();
|
||||
resultBuffer = output;
|
||||
if (size.width !== size2.width) {
|
||||
resultBuffer = await gm(output).gravity("West").chop(size2.width - size.width, 0).bufferPromise(image.type);
|
||||
}
|
||||
const output = await gm(image.path).coalesce().background("white").extent("%[fx:u.w]", "%[fx:u.h+15]").out("null:").out(watermark).gravity("SouthEast").compose("over").out("-layers", "composite").bufferPromise(image.type);
|
||||
return message.channel.createMessage("", {
|
||||
file: resultBuffer,
|
||||
file: output,
|
||||
name: `memecenter.${image.type}`
|
||||
});
|
||||
};
|
||||
|
|
|
@ -12,8 +12,7 @@ exports.run = async (message, args) => {
|
|||
const text = `/tmp/${Math.random().toString(36).substring(2, 15)}.png`;
|
||||
const text2 = `/tmp/${Math.random().toString(36).substring(2, 15)}.png`;
|
||||
const buffer = await gm().in("(").in(image.path).coalesce().resize(500, 500).borderColor("black").border(5, 5).out(")").borderColor("white").border(3, 3).bufferPromise("miff");
|
||||
const size = await gm(buffer).sizePromise();
|
||||
await gm(buffer).coalesce().background("black").gravity("Center").extent(600, size.height + 50).writePromise(file);
|
||||
await gm(buffer).coalesce().background("black").gravity("Center").extent(600, "%[fx:s.h+50]").writePromise(file);
|
||||
const size2 = await gm(file).sizePromise();
|
||||
await gm().background("black").out("-size", "600").fill("white").font("Times").pointSize(56).gravity("Center").out(`pango:${topText.replace(/&/g, "\\&").replace(/>/g, "\\>").replace(/</g, "\\<").replace(/"/g, "\\"").replace(/'/g, "\\'")}`).gravity("South").out("-splice", bottomText ? "0x0" : "0x20").writePromise(text);
|
||||
const size3 = await gm(text).sizePromise();
|
||||
|
|
|
@ -7,8 +7,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 Shutterstock watermark!`;
|
||||
const watermark = "./assets/images/shutterstock.png";
|
||||
const size = await gm(image.path).sizePromise();
|
||||
const buffer = await gm(image.path).coalesce().out("null:").out(watermark).gravity("Center").resize(null, size.height).out("-layers", "composite").bufferPromise(image.type);
|
||||
const buffer = await gm(image.path).coalesce().out("null:").out(watermark).gravity("Center").resize(null, "%[fx:u.h]").out("-layers", "composite").bufferPromise(image.type);
|
||||
return message.channel.createMessage("", {
|
||||
file: buffer,
|
||||
name: `shutterstock.${image.type}`
|
||||
|
|
|
@ -11,6 +11,7 @@ exports.run = async (message) => {
|
|||
const size = await gm(image.path).sizePromise();
|
||||
await gm(image.path).coalesce().gravity("East").crop("50%", 0).out("+repage").writePromise(data2);
|
||||
await gm(data2).flop().writePromise(data);
|
||||
// const buffer = await gm(data2).extent("%[fx:u.w*2]", "%[fx:u.h]").out("null:").out(data).gravity("West").out("-layers", "Composite").bufferPromise(image.type);
|
||||
const buffer = await gm(data2).extent(size.width, size.height).out("null:").out(data).geometry(`+${size.width / 2}+0`).out("-layers", "Composite").bufferPromise(image.type);
|
||||
return message.channel.createMessage("", {
|
||||
file: buffer,
|
||||
|
|
|
@ -6,9 +6,7 @@ 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 stretch!`;
|
||||
const size = await gm(image.path).sizePromise();
|
||||
if (size.width > 10000) return `${message.author.mention}, this image is too wide!`;
|
||||
const buffer = await gm(image.path).coalesce().resize(`${(size.width * 19) / 2}x${size.height / 2}!`).bufferPromise(image.type);
|
||||
const buffer = await gm(image.path).coalesce().resize("%[fx:(u.w*19)/2]x%[fx:u.h/2]!").bufferPromise(image.type);
|
||||
return message.channel.createMessage("", {
|
||||
file: buffer,
|
||||
name: `wide.${image.type}`
|
||||
|
|
|
@ -8,10 +8,9 @@ exports.run = async (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)}.miff`;
|
||||
const data2 = `/tmp/${Math.random().toString(36).substring(2, 15)}.miff`;
|
||||
const size = await gm(image.path).sizePromise();
|
||||
await gm(image.path).coalesce().gravity("North").crop(0, "50%").out("+repage").writePromise(data2);
|
||||
await gm(data2).flip().writePromise(data);
|
||||
const buffer = await gm(data2).extent(size.width, size.height).out("null:").out(data).geometry(`+0+${size.height / 2}`).out("-layers", "Composite").bufferPromise(image.type);
|
||||
const buffer = await gm(data2).extent("%[fx:u.w]", "%[fx:u.h*2]").out("null:").out(data).gravity("South").out("-layers", "Composite").bufferPromise(image.type);
|
||||
return message.channel.createMessage("", {
|
||||
file: buffer,
|
||||
name: `woow.${image.type}`
|
||||
|
|
7
package-lock.json
generated
7
package-lock.json
generated
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "esmbot",
|
||||
"version": "1.2.1",
|
||||
"version": "1.2.2",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
@ -1193,9 +1193,8 @@
|
|||
"dev": true
|
||||
},
|
||||
"gm": {
|
||||
"version": "1.23.1",
|
||||
"resolved": "https://registry.npmjs.org/gm/-/gm-1.23.1.tgz",
|
||||
"integrity": "sha1-Lt7rlYCE0PjqeYjl2ZWxx9/BR3c=",
|
||||
"version": "github:TheEssem/gm#6c8e444106b20d868e3bcdd6791cbc7c90ae5cab",
|
||||
"from": "github:TheEssem/gm",
|
||||
"requires": {
|
||||
"array-parallel": "~0.1.3",
|
||||
"array-series": "~0.1.5",
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
"emoji-regex": "^8.0.0",
|
||||
"eris": "^0.11.2",
|
||||
"file-type": "^13.1.0",
|
||||
"gm": "^1.23.1",
|
||||
"gm": "github:TheEssem/gm",
|
||||
"jsqr": "^1.2.0",
|
||||
"moment": "^2.24.0",
|
||||
"moment-duration-format": "^2.3.2",
|
||||
|
|
|
@ -11,9 +11,11 @@ You can invite the bot to your server using this link: https://projectlounge.pw/
|
|||
|
||||
A command list can be found [here](https://projectlounge.pw/esmBot/help.html).
|
||||
|
||||
If you want to run it locally for testing purposes, you should install ImageMagick, FFmpeg, and MongoDB:
|
||||
If you want to run it locally for testing purposes, you should install ImageMagick (version >=7), FFmpeg, and MongoDB:
|
||||
|
||||
```shell
|
||||
# In many cases you will need to build ImageMagick from source instead of installing from apt/similar package managers.
|
||||
# Instructions to do so can be found here: https://imagemagick.org/script/install-source.php
|
||||
sudo apt-get install imagemagick ffmpeg mongodb
|
||||
```
|
||||
|
||||
|
|
Loading…
Reference in a new issue