Ported even more commands to Magick++
This commit is contained in:
parent
950ce00a80
commit
78dbeabd39
24 changed files with 468 additions and 65 deletions
|
@ -5,7 +5,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 promisify(magick.blur)(image.path, image.type.toUpperCase(), image.delay ? (100 / image.delay.split("/")[0]) * image.delay.split("/")[1] : 0);
|
||||
const buffer = await promisify(magick.blur)(image.path, false, image.type.toUpperCase(), image.delay ? (100 / image.delay.split("/")[0]) * image.delay.split("/")[1] : 0);
|
||||
return {
|
||||
file: buffer,
|
||||
name: `blur.${image.type}`
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
const gm = require("gm").subClass({
|
||||
imageMagick: true
|
||||
});
|
||||
const magick = require("../build/Release/image.node");
|
||||
const { promisify } = require("util");
|
||||
|
||||
exports.run = async (message, args) => {
|
||||
const image = await require("../utils/imagedetect.js")(message);
|
||||
|
@ -9,26 +8,10 @@ exports.run = async (message, args) => {
|
|||
if (args.length === 0) return `${message.author.mention}, you need to provide some text to make a motivational poster!`;
|
||||
const processMessage = await message.channel.createMessage("<a:processing:479351417102925854> Processing... This might take a while");
|
||||
const [topText, bottomText] = newArgs.join(" ").split(/(?<!\\),/).map(elem => elem.trim());
|
||||
const file = `/tmp/${Math.random().toString(36).substring(2, 15)}.miff`;
|
||||
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().scale(500, 500).borderColor("black").border(5, 5).out(")").borderColor("white").border(3, 3).bufferPromise("miff", image.delay);
|
||||
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();
|
||||
const command2 = gm(file).gravity("North").coalesce().extent(600, size2.height + size3.height).out("null:", "(", text, "-set", "page", `+0+${size2.height}`, ")", "-layers", "composite");
|
||||
let resultBuffer;
|
||||
if (bottomText) {
|
||||
await gm().background("black").out("-size", "600").fill("white").font("Times").pointSize(28).gravity("Center").out(`pango:${bottomText.replace(/&/g, "\\&").replace(/>/g, "\\>").replace(/</g, "\\<").replace(/"/g, "\\"").replace(/'/g, "\\'")}`).gravity("South").out("-splice", "0x20").writePromise(text2);
|
||||
const size4 = await gm(text2).sizePromise();
|
||||
resultBuffer = await gm(await command2.bufferPromise(image.type, image.delay)).gravity("North").coalesce().extent(600, size2.height + size3.height + size4.height).out("null:", "(", text2, "-set", "page", `+0+${size2.height + size3.height}`, ")", "-layers", "composite").bufferPromise(image.type, image.delay);
|
||||
} else {
|
||||
resultBuffer = await command2.bufferPromise(image.type, image.delay);
|
||||
}
|
||||
const buffer = await promisify(magick.motivate)(image.path, topText.replace(/&/g, "\\&").replace(/>/g, "\\>").replace(/</g, "\\<").replace(/"/g, "\\"").replace(/'/g, "\\'"), bottomText ? bottomText.replace(/&/g, "\\&").replace(/>/g, "\\>").replace(/</g, "\\<").replace(/"/g, "\\"").replace(/'/g, "\\'") : "", image.type.toUpperCase(), image.delay ? (100 / image.delay.split("/")[0]) * image.delay.split("/")[1] : 0);
|
||||
processMessage.delete();
|
||||
return {
|
||||
file: resultBuffer,
|
||||
file: buffer,
|
||||
name: `motivate.${image.type}`
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
const gm = require("gm").subClass({
|
||||
imageMagick: true
|
||||
});
|
||||
const magick = require("../build/Release/image.node");
|
||||
const { promisify } = require("util");
|
||||
|
||||
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 pixelate!`;
|
||||
const buffer = await gm(image.path).coalesce().scale("10%").coalesce().scale("1000%").bufferPromise(image.type, image.delay);
|
||||
const buffer = await promisify(magick.resize)(image.path, image.type.toUpperCase(), image.delay ? (100 / image.delay.split("/")[0]) * image.delay.split("/")[1] : 0);
|
||||
return {
|
||||
file: buffer,
|
||||
name: `pixelate.${image.type}`
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
const gm = require("gm").subClass({
|
||||
imageMagick: true
|
||||
});
|
||||
const magick = require("../build/Release/image.node");
|
||||
const { promisify } = require("util");
|
||||
|
||||
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 a GIF to reverse!`;
|
||||
if (image.type !== "gif") return `${message.author.mention}, that isn't a GIF!`;
|
||||
const buffer = await gm(image.path).coalesce().out("-reverse").bufferPromise(image.type, image.delay);
|
||||
const buffer = await promisify(magick.reverse)(image.path, image.delay ? (100 / image.delay.split("/")[0]) * image.delay.split("/")[1] : 0);
|
||||
return {
|
||||
file: buffer,
|
||||
name: "reverse.gif"
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
const gm = require("gm").subClass({
|
||||
imageMagick: true
|
||||
});
|
||||
const magick = require("../build/Release/image.node");
|
||||
const { promisify } = require("util");
|
||||
|
||||
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 a Scott the Woz TV meme!`;
|
||||
const template = "./assets/images/scott.png";
|
||||
const buffer = await 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").bufferPromise(image.type, image.delay);
|
||||
//const template = "./assets/images/scott.png";
|
||||
//const buffer = await 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").bufferPromise(image.type, image.delay);
|
||||
const buffer = await promisify(magick.scott)(image.path, image.type.toUpperCase(), image.delay ? (100 / image.delay.split("/")[0]) * image.delay.split("/")[1] : 0);
|
||||
return {
|
||||
file: buffer,
|
||||
name: `scott.${image.type}`
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
const gm = require("gm").subClass({
|
||||
imageMagick: true
|
||||
});
|
||||
const magick = require("../build/Release/image.node");
|
||||
const { promisify } = require("util");
|
||||
|
||||
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 sharpen!`;
|
||||
const buffer = await gm(image.path).coalesce().sharpen(10, 3).bufferPromise(image.type, image.delay);
|
||||
const buffer = await promisify(magick.blur)(image.path, true, image.type.toUpperCase(), image.delay ? (100 / image.delay.split("/")[0]) * image.delay.split("/")[1] : 0);
|
||||
return {
|
||||
file: buffer,
|
||||
name: `sharpen.${image.type}`
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
const gm = require("gm").subClass({
|
||||
imageMagick: true
|
||||
});
|
||||
const magick = require("../build/Release/image.node");
|
||||
const { promisify } = require("util");
|
||||
|
||||
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 a Shutterstock watermark!`;
|
||||
const watermark = "./assets/images/shutterstock.png";
|
||||
const buffer = await gm(image.path).coalesce().out("null:").out(watermark).gravity("Center").scale(null, "%[fx:u.h]").out("-layers", "composite").bufferPromise(image.type, image.delay);
|
||||
const buffer = await promisify(magick.watermark)(image.path, "./assets/images/shutterstock.png", 5, true, false, false, image.type.toUpperCase(), image.delay ? (100 / image.delay.split("/")[0]) * image.delay.split("/")[1] : 0);
|
||||
return {
|
||||
file: buffer,
|
||||
name: `shutterstock.${image.type}`
|
||||
|
|
|
@ -1,15 +1,12 @@
|
|||
const gm = require("gm").subClass({
|
||||
imageMagick: true
|
||||
});
|
||||
const magick = require("../build/Release/image.node");
|
||||
const { promisify } = require("util");
|
||||
|
||||
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 a GIF to slow down!`;
|
||||
if (image.type !== "gif") return `${message.author.mention}, that isn't a GIF!`;
|
||||
const value = await gm(image.path).identifyPromise();
|
||||
const delay = value.Delay ? value.Delay[0].split("x") : [0, 100];
|
||||
const buffer = await gm().delay(`${parseInt(delay[0]) * 2}x${delay[1]}`).out(image.path).bufferPromise(image.type, image.delay);
|
||||
const buffer = await promisify(magick.speed)(image.path, true, image.type.toUpperCase(), image.delay ? (100 / image.delay.split("/")[0]) * image.delay.split("/")[1] : 0);
|
||||
return {
|
||||
file: buffer,
|
||||
name: "slow.gif"
|
||||
|
|
|
@ -1,16 +1,14 @@
|
|||
const gm = require("gm").subClass({
|
||||
imageMagick: true
|
||||
});
|
||||
const magick = require("../build/Release/image.node");
|
||||
const { promisify } = require("util");
|
||||
const wrap = require("../utils/wrap.js");
|
||||
|
||||
exports.run = async (message, args) => {
|
||||
if (args.length === 0) return `${message.author.mention}, you need to provide some text to make a Sonic meme!`;
|
||||
message.channel.sendTyping();
|
||||
const template = "./assets/images/sonic.jpg";
|
||||
const file = `/tmp/${Math.random().toString(36).substring(2, 15)}.png`;
|
||||
const cleanedMessage = args.join(" ").replace(/&/g, "\\&").replace(/>/g, "\\>").replace(/</g, "\\<").replace(/"/g, "\\"").replace(/'/g, "\\'");
|
||||
await gm(474, 332).out("+size").background("none").gravity("Center").out("-pointsize", 72).out("-font", "Bitstream Vera Sans").out(`pango:<span foreground="white">${wrap(cleanedMessage, {width: 15, indent: ""})}</span>`).writePromise(file);
|
||||
const buffer = await gm(template).composite(file).gravity("Center").geometry("474x332+160+10").bufferPromise("png", null, "sonic");
|
||||
/*await gm(474, 332).out("+size").background("none").gravity("Center").out("-pointsize", 72).out("-font", "Bitstream Vera Sans").out(`pango:<span foreground="white">${wrap(cleanedMessage, {width: 15, indent: ""})}</span>`).writePromise(file);
|
||||
const buffer = await gm(template).composite(file).gravity("Center").geometry("474x332+160+10").bufferPromise("png", null, "sonic");*/
|
||||
const buffer = await promisify(magick.sonic)(wrap(cleanedMessage, {width: 15, indent: ""}));
|
||||
return {
|
||||
file: buffer,
|
||||
name: "sonic.png"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue