diff --git a/assets/images/sketch.jpg b/assets/images/sketch.jpg new file mode 100644 index 00000000..09617ad5 Binary files /dev/null and b/assets/images/sketch.jpg differ diff --git a/assets/images/spaghetti.jpg b/assets/images/spaghetti.jpg deleted file mode 100644 index c37e0006..00000000 Binary files a/assets/images/spaghetti.jpg and /dev/null differ diff --git a/commands/edit-image/sketch.js b/commands/edit-image/sketch.js index f37190ab..f9c9359b 100644 --- a/commands/edit-image/sketch.js +++ b/commands/edit-image/sketch.js @@ -1,8 +1,9 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const gm = require('gm').subClass({ imageMagick: '7+' }); const request = require('node-superfetch'); -const { magikToBuffer, reactIfAble } = require('../../util/Util'); +const { readFile } = require('fs/promises'); +const path = require('path'); +const { reactIfAble } = require('../../util/Util'); const { LOADING_EMOJI_ID, SUCCESS_EMOJI_ID } = process.env; module.exports = class SketchCommand extends Command { @@ -18,13 +19,6 @@ module.exports = class SketchCommand extends Command { duration: 60 }, clientPermissions: [PermissionFlagsBits.AttachFiles], - credit: [ - { - name: 'ImageMagick', - url: 'https://imagemagick.org/index.php', - reason: 'Image Manipulation' - } - ], args: [ { key: 'image', @@ -37,15 +31,11 @@ module.exports = class SketchCommand extends Command { async run(msg, { image }) { const { body } = await request.get(image); + const style = await readFile(path.join(__dirname, '..', '..', 'assets', 'images', 'sketch.jpg')); await reactIfAble(msg, msg.author, LOADING_EMOJI_ID, '💬'); - const magik = gm(body); - magik.colorspace('gray'); - magik.out('-sketch'); - magik.out('0x20+120'); - magik.setFormat('png'); - const attachment = await magikToBuffer(magik); + const attachment = await this.client.tensorflow.stylizeImage(body, style); await reactIfAble(msg, msg.author, SUCCESS_EMOJI_ID, '✅'); if (Buffer.byteLength(attachment) > 2.5e+7) return msg.reply('Resulting image was above 25 MB.'); - return msg.say({ files: [{ attachment, name: 'sketch.png' }] }); + return msg.say({ files: [{ attachment, name: 'sketch.jpg' }] }); } }; diff --git a/commands/edit-image/spaghetti.js b/commands/edit-image/spaghetti.js deleted file mode 100644 index 5d9d578e..00000000 --- a/commands/edit-image/spaghetti.js +++ /dev/null @@ -1,41 +0,0 @@ -const Command = require('../../framework/Command'); -const { PermissionFlagsBits } = require('discord.js'); -const request = require('node-superfetch'); -const { readFile } = require('fs/promises'); -const path = require('path'); -const { reactIfAble } = require('../../util/Util'); -const { LOADING_EMOJI_ID, SUCCESS_EMOJI_ID } = process.env; - -module.exports = class SpaghettiCommand extends Command { - constructor(client) { - super(client, { - name: 'spaghetti', - aliases: ['spaghettify', 'spaghet', 'pasta'], - group: 'edit-image', - memberName: 'spaghetti', - description: 'Draws an image or a user\'s avatar but as spaghetti.', - throttling: { - usages: 1, - duration: 120 - }, - clientPermissions: [PermissionFlagsBits.AttachFiles], - args: [ - { - key: 'image', - type: 'image-or-avatar', - default: msg => msg.author.displayAvatarURL({ extension: 'png', size: 512 }) - } - ] - }); - } - - async run(msg, { image }) { - const { body } = await request.get(image); - const style = await readFile(path.join(__dirname, '..', '..', 'assets', 'images', 'spaghetti.jpg')); - await reactIfAble(msg, msg.author, LOADING_EMOJI_ID, '💬'); - const attachment = await this.client.tensorflow.stylizeImage(body, style); - await reactIfAble(msg, msg.author, SUCCESS_EMOJI_ID, '✅'); - if (Buffer.byteLength(attachment) > 2.5e+7) return msg.reply('Resulting image was above 25 MB.'); - return msg.say({ files: [{ attachment, name: 'spaghetti.jpg' }] }); - } -};