如何修复GraphicsMagik错误(GM CONVERT:此图像格式没有解码委托) [英] How to fix the GraphicsMagik error (gm convert: No decode delegate for this image format)

查看:45
本文介绍了如何修复GraphicsMagik错误(GM CONVERT:此图像格式没有解码委托)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我正在尝试开发一个小应用程序,它可以接收PDF文件并将其转换为node.js中的图片。

我发现pdf2pic包非常适合我想做的事情。

因此,按照该软件包中的说明,我去安装了Ghostscript和Graphicsmagick,然后安装了该软件包。我正在使用Windows btw。

以下是我的node.js代码:

const { fromPath } = require("pdf2pic");

const options = {
  density: 100,
  saveFilename: "untitled",
  savePath: "./images",
  format: "png",
  width: 600,
  height: 600
};
const storeAsImage = fromPath("test.pdf", options);
const pageToConvertAsImage = 1;

storeAsImage(pageToConvertAsImage).then((resolve) => {
  console.log("Page 1 is now converted as image");

  return resolve;
}).catch(error => {
    console.log(error);
});

在我调整此代码后,我收到此错误:

Error: Command failed: gm convert: No decode delegate for this image format (C:UsersYosse_MAppDataLocalTempgmRuQc4v).

    at ChildProcess.onExit (D:DevsNodeJSapp07-pdf2pic-test
ode_modulesgmlibcommand.js:301:17)
    at ChildProcess.emit (events.js:315:20)
    at ChildProcess.cp.emit (D:DevsNodeJSapp07-pdf2pic-test
ode_modulescross-spawnlibenoent.js:40:29)
    at maybeClose (internal/child_process.js:1021:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5) {
  code: 1,
  signal: null

下面是命令gm-version返回的内容:

C:UsersYosse_M>gm -version
GraphicsMagick 1.3.36 20201226 Q16 http://www.GraphicsMagick.org/
Copyright (C) 2002-2020 GraphicsMagick Group.
Additional copyrights and licenses apply to this software.
See http://www.GraphicsMagick.org/www/Copyright.html for details.

Feature Support:
  Native Thread Safe         yes
  Large Files (> 32 bit)     yes
  Large Memory (> 32 bit)    yes
  BZIP                       yes
  DPS                        no
  FlashPix                   no
  FreeType                   yes
  Ghostscript (Library)      no
  JBIG                       yes
  JPEG-2000                  yes
  JPEG                       yes
  Little CMS                 yes
  Loadable Modules           yes
  Solaris mtmalloc           no
  Google perftools tcmalloc  no
  OpenMP                     yes (200203 "2.0")
  PNG                        yes
  TIFF                       yes
  TRIO                       no
  Solaris umem               no
  WebP                       yes
  WMF                        yes
  X11                        no
  XML                        yes
  ZLIB                       yes

Windows Build Parameters:

  MSVC Version:            1500

我不知道如何着手解决此问题,请给我一些建议。

如果您需要更多信息,请让我知道。

谢谢

推荐答案

我也在努力解决通用汽车的代表问题。我还发现GraphicsMagick使用Ghostscript字体(也称为URW字体)来支持标准的Adobe PostScript字体集,如&Helvetica&Quot;和&Quot;Times Roman&Quot;。 从此处下载字体Ghostscript Fonts并将下载的文件夹字体粘贴到包含Ghostscript文件的文件夹C:Program Filesgsgs9.52Here您可以找到更多信息。

const { fromPath } = require("pdf2pic");

const options = {
  density: 100,
  saveFilename: "untitled",
  savePath: "./images",
  format: "png",
  width: 600,
  height: 600
};

try {
    const convert = fromPath("test.pdf", options);
    await convert.bulk(-1);
} catch (error) {
    console.log(error);

}

这篇关于如何修复GraphicsMagik错误(GM CONVERT:此图像格式没有解码委托)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆