【问题标题】:How to debug MagickReadImage fail when no Exception occurs未发生异常时如何调试 MagickReadImage 失败
【发布时间】:2017-01-23 09:36:44
【问题描述】:

我有一些 MagickWand 代码,其中 MagickReadImage() 在另一个系统上运行失败(返回 MagickFalse)。

现在没有异常发生,MagickGetException() 返回一个空字符串,如果我正确理解文档,这意味着没有异常。

我要打开的文件就在那里,可以用同一用户下的其他工具打开,而且我使用的magick_wand不为NULL。

调用周围的代码基本上是这样的:

    // read image
    MagickBooleanType status = MagickReadImage(magick_wand, fn_selector);

    // make sure it worked
    if (status == MagickFalse)
    {
            char *description;
            ExceptionType severity;
            description=MagickGetException(magick_wand,&severity);
            fprintf(stderr,"%s %s %lu :%s: %u\n",GetMagickModule(),description,severity);
            description=(char *) MagickRelinquishMemory(description);
            fprintf(stderr, "magickwand couldn't read file %s\n", fn_selector);
            exit(1);
    }

有什么方法可以找出函数调用失败的原因吗? MagickReadImage() 似乎调用了一个不容易调试的内部函数,如果不是绝对必要的话,我不想自己构建 MagickWand 库并添加调试内容。

使用 MagickWand 版本 6.8.9.9 (debian jessie)

【问题讨论】:

    标签: c++ imagemagick magickwand


    【解决方案1】:

    原来(通过strace 之后)ImageMagick 的 PDF 阅读部分需要在系统上安装 ghostscript 可执行文件 (/usr/bin/gs)。现在通过 Debian apt 包管理器安装 ImageMagick 时,ghostscript 不是依赖项,只是 Magick 库的推荐。不幸的是,Magick 认为没有必要在读取调用失败时以任何方式通知您缺少库组件。

    安装ghostscript 包后,一切正常。

    【讨论】:

      猜你喜欢
      • 2020-11-11
      • 2014-08-11
      • 2022-01-24
      • 2021-04-12
      • 2023-03-07
      • 1970-01-01
      • 2017-07-11
      • 2019-10-13
      • 1970-01-01
      相关资源
      最近更新 更多