gm
gm copied to clipboard
Can't get gm to switch fonts
I am trying to use this script to write out something on a photo. It's working properly, however, I can't get the font to change, even though I am using an example straight from the docs. I have ghostscript installed and if I run
$ convert -list font
I see a large amount of fonts, but even using those in the below fashion doesn't do anything. Any ideas on what I'm doing wrong?
gm('./photoRealistic.png')
.fill('#000000')
.font("Helvetica.ttf", 30)
.drawText(0, 250, "Hello!")
.write("./drawing2.jpg", function (err) {
if(err) console.log(err);
if (!err) console.log('done');
});
Any solution or work around to this?
Replacing
const gm = require('gm');
with
const gm = require('gm').subClass({imageMagick: true});
helped me.
I got the same problem. I'm tried out different fonts, but result is the same.
gm('./public/img/pattern-changed.jpg') .font('Arial.ttf', 16) .drawText(300, 39,
${obj.article}) .drawText(300, 58,${obj.size}) .drawText(12, 100, obj.title.match(/женская/) ? 'футболка женская' : 'футболка мужская' ) .drawText(12, 455,${obj.title}) .write(./public/upload/${obj.barcode}.jpg, (err) => { if (!err) { console.log('done'); }
You need to add the fonts to imageMagick's xml file