[英]How to change font weight of text added on image using gm
I am using gm for adding text on the image.我正在使用 gm 在图像上添加文本。 Now I want to make it bold, but I am not getting an option to change the font-weight.
现在我想让它加粗,但我没有选择更改字体粗细。 Any help is appreciated.
任何帮助表示赞赏。
const gm = require('gm').subClass({imageMagick: true});
const imageUrl = 'image_url'
const text = 'Some_text';
const image = gm(`${imageUrl}`)
.resize(518, 500)
.fill('#f2f2f2')
.font('Arial', 14)
.drawText(115, 470, `${text}`);
image.write(`result.png`, err => {
if(err) return console.error(err);
console.log('done');
});
You can use gm.in() Custom Arguments like below您可以使用 gm.in() 自定义参数,如下所示
const gm = require('gm').subClass({imageMagick: true});
const imageUrl = 'image_url'
const text = 'Some_text';
const image = gm(`${imageUrl}`)
.resize(518, 500)
.fill('#f2f2f2')
.font('Arial', 14)
.in('-weight', 'Bold')
.drawText(115, 470, `${text}`);
image.write(`result.png`, err => {
if(err) return console.error(err);
console.log('done');
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.