2013-12-19 89 views
0

我试图运行node.js gm项目中的例子来创建一个图像(new.js)。我安装了Windows 7和GraphicsMagick-1.3.18-Q8。nodejs gm写入图像时出错

代码:

var fs = require('fs'), 
gm = require('gm'), 
dir = __dirname + '/imgs'; 

gm(525, 110, "#00ff55aa") 
    .fontSize(68) 
    .stroke("#efe", 2) 
    .fill("#555") 
    .drawText(20, 72, "graphics") 
    .fill("#fa0") 
    .drawText(274, 72, " magick") 
    .write(dir + '/new.png', function(err){ 
    if (err) return console.dir(arguments) 
    console.log(this.outname + ' created :: ' + arguments[3]) 
    } 
) 

错误:

{ 
    '0': { [Error: Command failed: gm convert: Unable to read font (n019003l.pfb) [Nosuch file or directory].] code: 1, signal: null }, 
    '1': '', 
    '2': 'gm convert: Unable to read font (n019003l.pfb) [No such file or directory].\r\n', 
    '3': 'gm "convert" "-size" "525x110" "xc:#00ff55aa" "-pointsize" "68" "-strokewidth" "2" "-stroke" "#efe" "-fill" "#555" "-draw" "text 20,72 \\"graphics\\"" "-fill" "#fa0" "-draw" "text 274,72 \\"magick\\"" "C:\\Users\\Owner\\Practice\\youtube/imgs/new.png"' 
} 

任何帮助表示赞赏。

+0

我读过的答案说,要安装Ghostscript,我做了但没有变化 – iona1

+0

我有这个问题。我不得不安装ghostscript,然后用brew重新安装graphicsmagick,问题就消失了。 – forrestranger

回答

0

Windows 10在这里。

我不认为ghostscript真的是必要的,因为它不包括在Windows上的这种字体,但字体可以在github.com/fontforge找到并放在工作目录中。