height and width option

This commit is contained in:
loicbersier 2020-02-21 20:00:11 +01:00
parent 7cc57629cf
commit d4fbb7deaa

View file

@ -25,12 +25,24 @@ class posterCommand extends Command {
}, },
type: 'string', type: 'string',
match: 'rest' match: 'rest'
} },
{
id: 'width',
match: 'option',
flag: '--width',
default: 50
},
{
id: 'height',
match: 'option',
flag: '--height',
default: 200
},
], ],
description: { description: {
content: 'Create demotivational poster (use ``|`` to separate top text and bottom text) WIP', content: 'Create demotivational poster (use ``|`` to separate top text and bottom text) WIP',
usage: '[link to image] [topText|bottomText]', usage: '[link to image] [topText|bottomText] (optional) [--width number] [--height number]',
examples: [''] examples: ['https://cdn.discordapp.com/attachments/484013245158522909/679686216903426104/0nhsxje5vfg41-1.jpg NO PLEASE DON\'T | My mom said im not allowed to']
} }
}); });
} }
@ -84,6 +96,10 @@ class posterCommand extends Command {
const FONT_SIZE1 = (value.width / 12); const FONT_SIZE1 = (value.width / 12);
const FONT_SIZE2 = (value.width / 12) - 15; const FONT_SIZE2 = (value.width / 12) - 15;
let BORDER_WIDTH = args.width;
let BORDER_HEIGHT = args.height;
// Write text on image using graphicsmagick // Write text on image using graphicsmagick
img.borderColor('black') img.borderColor('black')
.border(3,3) .border(3,3)
@ -91,7 +107,7 @@ class posterCommand extends Command {
.frame(1,1,0,0.5) .frame(1,1,0,0.5)
.border(1,1) .border(1,1)
.borderColor('black') .borderColor('black')
.border(50,200) .border(BORDER_WIDTH,BORDER_HEIGHT)
.fill(FONT_FILL) .fill(FONT_FILL)
.stroke(STROKE_COLOR, -2) .stroke(STROKE_COLOR, -2)
.font(FONT, FONT_SIZE1) .font(FONT, FONT_SIZE1)