如何检查libpng版本

How to check libpng version

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

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

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

最简单的方法是运行

convert -list format | grep PNG

identify -list format | grep PNG

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

有时您会看到类似

的内容

PNG* rw- Portable Network Graphics (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。

这个Ruby一行只显示数字:

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