【问题标题】:How to check libpng version如何检查 libpng 版本
【发布时间】:2016-02-11 14:10:58
【问题描述】:

我正在使用imagemagick,据我了解,它将png 文件的处理委托给libpng 库,所以我想知道如何检查使用的libpng 版本?

【问题讨论】:

    标签: imagemagick libpng


    【解决方案1】:

    您可以尝试以下任一方法:

    convert -debug coder xc: a.png 2>&1 | grep version
    
      IM version     = 6.9.2-5
      Libpng version = 1.6.18
      Zlib version   = 1.2.5
    

    或者,这个

    identify -list configure| grep CFLAGS
    
    CFLAGS         -I/usr/include/libxml2 -I/usr/local/Cellar/libpng/1.6.18/include/libpng16 -I/usr/local/Cellar/freetype/2.6_1/include/freetype2 -I/usr/local/Cellar/fontconfig/2.11.1/include -I/usr/local/Cellar/freetype/2.6_1/include/freetype2 -I/usr/local/Cellar/pixman/0.32.8/include/pixman-1 -I/usr/local/Cellar/glib/2.46.1_1/include/glib-2.0 -I/usr/local/Cellar/glib/2.46.1_1/lib/glib-2.0/include -I/usr/local/opt/gettext/include -I/usr/local/Cellar/cairo/1.14.4/include/cairo -D_REENTRANT -I/usr/local/Cellar/libpng/1.6.18/include/libpng16 -I/usr/local/Cellar/freetype/2.6_1/include/freetype2 -I/usr/local/Cellar/fontconfig/2.11.1/include -I/usr/local/Cellar/freetype/2.6_1/include/freetype2 -I/usr/local/Cellar/pixman/0.32.8/include/pixman-1 -I/usr/local/Cellar/glib/2.46.1_1/include/glib-2.0 -I/usr/local/Cellar/glib/2.46.1_1/lib/glib-2.0/include -I/usr/local/opt/gettext/include -I/usr/local/Cellar/cairo/1.14.4/include/cairo -I/usr/local/Cellar/gdk-pixbuf/2.32.1/include/gdk-pixbuf-2.0 -I/usr/local/Cellar/librsvg/2.40.11/include/librsvg-2.0 -I/usr/local/Cellar/libpng/1.6.18/include/libpng16 -I/usr/local/Cellar/xz/5.2.2/include -I/usr/local/Cellar/freetype/2.6_1/include/freetype2 -I/usr/local/Cellar/freetype/2.6_1/include/freetype2 -I/usr/local/Cellar/fontconfig/2.11.1/include -I/usr/local/Cellar/freetype/2.6_1/include/freetype2    -g -O2 -Wall -mtune=core2 -fexceptions -D_FORTIFY_SOURCE=0 -D_THREAD_SAFE -pthread -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16
    PCFLAGS        -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16
    

    或者,在 Ubuntu 上

    strace  convert xc: a.png 2>&1 | grep open | grep libpng
    

    【讨论】:

    • 我使用的是 ubuntu 14.04 的默认配置,第一个命令什么也没返回,第二个命令没有提到 libpng,有没有可能它根本没有安装,尽管 imagemagick 工作得很好?
    • 为 Ubuntu 添加了一个 hack...@GlennRanders-Pehrson 可能知道一些更优雅的东西。
    • @GlennRanders-Pehrson 这比我乱搞更简单,更可取-请继续自己发布,您也将获得我的投票!感谢您的关注并让我诚实:-)
    【解决方案2】:

    最简单的方法是运行

    convert -list format | grep PNG
    

    identify -list format | grep PNG
    

    这会报告正在使用的 libpng 和 zlib 版本。

    有时你会看到类似的东西

    PNG* rw- 便携式网络图形 (libpng 1.6.17,1.6.18)

    这意味着 ImageMagick 是使用 libpng-1.6.17 编译的,并且使用更新的共享库 libpng-1.6.18 运行。这是无害的,除非这显示了两个不兼容的版本,例如 (libpng-1.2.44, 1.6.18)。

    在 Ubuntu 和其他 *nix 平台上,您还可以从中获取有用的信息

    ldd `which convert`
    

    如果后面的命令显示两个或多个 libpngNN 实例,请不要感到困惑;一个被 coders/png.c 用来解码 PNG,另一个在 freetype 中使用,如果你已经安装了 freetype。

    【讨论】:

      【解决方案3】:

      这个 Ruby 单行只显示数字:

      ruby -e 'im_formats = `convert -list format`; mdata = /(\(libpng\s)([^)]+)([)])/.match(im_formats); puts mdata[2];'
      => 1.6.34
      

      【讨论】:

        猜你喜欢
        • 2011-09-22
        • 2014-10-28
        • 2015-07-23
        • 1970-01-01
        • 2016-01-08
        • 2013-12-19
        • 2017-06-07
        • 2016-04-18
        相关资源
        最近更新 更多