如何在没有Exception发生的情况下调试MagickReadImage失败

How to debug MagickReadImage fail when no Exception occurs

本文关键字:情况下 调试 MagickReadImage 失败 Exception      更新时间:2023-10-16

我有一些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: %un",GetMagickModule(),description,severity);
            description=(char *) MagickRelinquishMemory(description);
            fprintf(stderr, "magickwand couldn't read file %sn", fn_selector);
            exit(1);
    }

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

使用MagickWand版本6.8.9.9 (debian jessie)

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

安装ghostscript包后,一切正常

相关文章: