From 4c5d879650687bfdc6ec913583a76b54ef601db9 Mon Sep 17 00:00:00 2001 From: Supositware Date: Mon, 8 Jul 2024 23:50:28 +0200 Subject: [PATCH] add autocrop --- commands/utility/vid2gif.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/commands/utility/vid2gif.js b/commands/utility/vid2gif.js index c9734ab..fd831f0 100644 --- a/commands/utility/vid2gif.js +++ b/commands/utility/vid2gif.js @@ -23,6 +23,10 @@ export default { option.setName('fps') .setDescription('Change the speed at which the gif play at. Default 20. Number between 1 and 100.') .setRequired(false)) + .addBooleanOption(option => + option.setName('autocrop') + .setDescription('Autocrop borders on gif.') + .setRequired(false)) .addBooleanOption(option => option.setName('noloop') .setDescription('Stop the gif from looping') @@ -62,7 +66,14 @@ export default { utils.downloadVideo(url, interaction.id) .then(async () => { const file = fs.readdirSync(os.tmpdir()).filter(fn => fn.startsWith(interaction.id)); - const output = `${os.tmpdir()}/${file}`; + let output = `${os.tmpdir()}/${file}`; + + if (args.autocrop) { + const oldOutput = output; + output = `${os.tmpdir()}/autocrop${file}`; + await utils.autoCrop(oldOutput, output); + } + const gifskiOutput = output.replace(path.extname(output), '.gif'); const gifsicleOutput = output.replace(path.extname(output), 'gifsicle.gif');