gm icon indicating copy to clipboard operation
gm copied to clipboard

Can't get gm to switch fonts

Open mayeaux opened this issue 9 years ago • 4 comments

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');
      });

mayeaux avatar Aug 10 '16 23:08 mayeaux

Any solution or work around to this?

jaladankisuresh avatar Mar 09 '17 09:03 jaladankisuresh

Replacing

const gm = require('gm');

with

const gm = require('gm').subClass({imageMagick: true});

helped me.

glenswift avatar Mar 15 '17 18:03 glenswift

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'); }

smwbtech avatar Oct 15 '17 08:10 smwbtech

You need to add the fonts to imageMagick's xml file

Aung-Myint-Thein avatar Sep 11 '20 09:09 Aung-Myint-Thein