forked from Supositware/Haha-Yes
Gif support
This commit is contained in:
parent
1ec9fa887f
commit
c98a572a02
1 changed files with 47 additions and 45 deletions
|
@ -36,8 +36,6 @@ class posterCommand extends Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
async exec(message, args) {
|
async exec(message, args) {
|
||||||
let output = `${os.tmpdir()}/poster${message.id}.jpg`;
|
|
||||||
|
|
||||||
let options = args.message.trim().split('|');
|
let options = args.message.trim().split('|');
|
||||||
|
|
||||||
if (options[0] == undefined)
|
if (options[0] == undefined)
|
||||||
|
@ -57,11 +55,11 @@ class posterCommand extends Command {
|
||||||
// Create new graphicsmagick instance
|
// Create new graphicsmagick instance
|
||||||
fetch(url)
|
fetch(url)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
const dest = fs.createWriteStream(`${os.tmpdir()}/${message.id}.jpg`);
|
const dest = fs.createWriteStream(`${os.tmpdir()}/${message.id}`);
|
||||||
res.body.pipe(dest);
|
res.body.pipe(dest);
|
||||||
dest.on('finish', async () => {
|
dest.on('finish', async () => {
|
||||||
|
|
||||||
let img = gm(`${os.tmpdir()}/${message.id}.jpg`);
|
let img = gm(`${os.tmpdir()}/${message.id}`);
|
||||||
|
|
||||||
// Set some defaults
|
// Set some defaults
|
||||||
const TOP_TEXT = options[0];
|
const TOP_TEXT = options[0];
|
||||||
|
@ -72,6 +70,8 @@ class posterCommand extends Command {
|
||||||
const STROKE_COLOR = '#000';
|
const STROKE_COLOR = '#000';
|
||||||
const PADDING = 40;
|
const PADDING = 40;
|
||||||
|
|
||||||
|
img.format(function(err, format) {
|
||||||
|
let output = `${os.tmpdir()}/poster${message.id}.${format.toLocaleLowerCase()}`;
|
||||||
// Get the image size to calculate top and bottom text positions
|
// Get the image size to calculate top and bottom text positions
|
||||||
img.size(function(err, value) {
|
img.size(function(err, value) {
|
||||||
// Set text position for top and bottom
|
// Set text position for top and bottom
|
||||||
|
@ -115,6 +115,8 @@ class posterCommand extends Command {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
});
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
|
|
Loading…
Reference in a new issue