Octave 无法使用 GraphicsMagick 读取文件
Octave can't read file using GraphicsMagick
我正在尝试在 OS X 上使用 GraphicsMagick 1.3.27(通过 brew)在 Octave 4.2.1 中加载图像。这是错误:
>> img = imread('./myimg.jpg')
error: Magick++ exception: octave-cli-4.2: No decode delegate for this
image format (<path to myimg.jpg>) reported by magick/constitute.c:1535 (ReadImage)
error: called from
__imread__ at line 80 column 10
imageIO at line 117 column 26
imread at line 106 column 30
GraphicsMagick 看起来配置正确:
gm -version
GraphicsMagick 1.3.27 Q16 http://www.GraphicsMagick.org/
Copyright (C) 2002-2017 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 no
JPEG-2000 no
JPEG yes
Little CMS no
Loadable Modules yes
OpenMP no
PNG yes
TIFF yes
TRIO no
UMEM no
WebP no
WMF no
X11 no
XML no
ZLIB yes
Host type: x86_64-apple-darwin16.7.0
Configured using the command:
./configure '--prefix=/usr/local/Cellar/graphicsmagick/1.3.27' '--
disable-dependency-tracking' '--enable-shared' '--disable-static' '--with-modules' '--without-lzma' '--disable-openmp' '--with-quantum-depth=16' '--disable-installed' '--without-gslib' '--with-gs-font-dir=/usr/local/share/ghostscript/fonts' '--without-x' '--without-lcms2' 'CC=clang' 'CXX=clang++'
Final Build Parameters:
CC = clang
CFLAGS = -g -O2 -Wall -D_THREAD_SAFE
CPPFLAGS = -I/usr/local/opt/freetype/include/freetype2
CXX = clang++
CXXFLAGS = -D_THREAD_SAFE
LDFLAGS = -L/usr/local/opt/freetype/lib
LIBS = -lfreetype -lbz2 -lz -lltdl -lm -lpthread
尝试加载 png 文件导致同样的错误。直接从命令行使用 gm
效果很好。
您的 Octave 和 gm 安装可能链接到不同的 GraphicsMagick 库,因此 gm -version
的输出可能不准确。您可能应该从 Octave 内部检查它,如下所示:
octave:1> imformats
Extension | isa | Info | Read | Write | Alpha | Description
----------+-----+------+------+-------+-------+------------
bmp | yes | yes | yes | yes | yes | Microsoft Windows bitmap image
cur | yes | yes | yes | no | yes | Microsoft Cursor Icon
gif | yes | yes | yes | yes | yes | CompuServe graphics interchange format
ico | yes | yes | yes | no | yes | Microsoft Icon
jbg | yes | yes | yes | yes | yes | Joint Bi-level Image experts Group interchange format
jbig | yes | yes | yes | yes | yes | Joint Bi-level Image experts Group interchange format
jpg, jpeg | yes | yes | yes | yes | yes | Joint Photographic Experts Group JFIF format
pbm | yes | yes | yes | yes | yes | Portable bitmap format (black/white)
pcx | yes | yes | yes | yes | yes | ZSoft IBM PC Paintbrush
pgm | yes | yes | yes | yes | yes | Portable graymap format (gray scale)
png | yes | yes | yes | yes | yes | Portable Network Graphics
pnm | yes | yes | yes | yes | yes | Portable anymap
ppm | yes | yes | yes | yes | yes | Portable pixmap format (color)
ras | yes | yes | yes | yes | yes | SUN Rasterfile
tga, tpic | yes | yes | yes | yes | yes | Truevision Targa image
tif, tiff | yes | yes | yes | yes | yes | Tagged Image File Format
xbm | yes | yes | yes | yes | yes | X Windows system bitmap (black/white)
xpm | yes | yes | yes | yes | yes | X Windows system pixmap (color)
xwd | yes | yes | yes | yes | yes | X Windows system window dump (color)
您还可以通过 ldd
检查 Octave 实际使用的库是什么(因为您使用的是 Mac,您可能没有 ldd
但 google 告诉我 otool -L
是 Mac 解决方案)。就我而言,我知道它们是相同的:
$ ldd /usr/local/lib/octave/5.0.0/liboctinterp.so | grep Magick
libGraphicsMagick++-Q16.so.12 => /lib/libGraphicsMagick++-Q16.so.12 (0x00007f858a896000)
libGraphicsMagick-Q16.so.3 => /lib/libGraphicsMagick-Q16.so.3 (0x00007f858a52e000)
$ ldd /usr/bin/gm | grep Magick
libGraphicsMagick-Q16.so.3 => /lib/libGraphicsMagick-Q16.so.3 (0x00007f5041f66000)
一旦您知道 Octave 为 GraphicsMagick 使用的实际库,您就可以检查该库是否链接到 libjpeg:
$ ldd /lib/libGraphicsMagick++-Q16.so.12 | grep jpeg
libjpeg.so.62 => /lib/x86_64-linux-gnu/libjpeg.so.62 (0x00007f63e910c000)
您也可以从八度配置中获得一些提示:
octave:1> __octave_config_info__.build_environment.MAGICK_CPPFLAGS
ans = -I/usr/include/GraphicsMagick
octave:2> __octave_config_info__.build_environment.MAGICK_LDFLAGS
ans =
octave:3> __octave_config_info__.build_environment.MAGICK_LIBS
ans = -lGraphicsMagick++ -lGraphicsMagick
我正在尝试在 OS X 上使用 GraphicsMagick 1.3.27(通过 brew)在 Octave 4.2.1 中加载图像。这是错误:
>> img = imread('./myimg.jpg')
error: Magick++ exception: octave-cli-4.2: No decode delegate for this
image format (<path to myimg.jpg>) reported by magick/constitute.c:1535 (ReadImage)
error: called from
__imread__ at line 80 column 10
imageIO at line 117 column 26
imread at line 106 column 30
GraphicsMagick 看起来配置正确:
gm -version
GraphicsMagick 1.3.27 Q16 http://www.GraphicsMagick.org/
Copyright (C) 2002-2017 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 no
JPEG-2000 no
JPEG yes
Little CMS no
Loadable Modules yes
OpenMP no
PNG yes
TIFF yes
TRIO no
UMEM no
WebP no
WMF no
X11 no
XML no
ZLIB yes
Host type: x86_64-apple-darwin16.7.0
Configured using the command:
./configure '--prefix=/usr/local/Cellar/graphicsmagick/1.3.27' '--
disable-dependency-tracking' '--enable-shared' '--disable-static' '--with-modules' '--without-lzma' '--disable-openmp' '--with-quantum-depth=16' '--disable-installed' '--without-gslib' '--with-gs-font-dir=/usr/local/share/ghostscript/fonts' '--without-x' '--without-lcms2' 'CC=clang' 'CXX=clang++'
Final Build Parameters:
CC = clang
CFLAGS = -g -O2 -Wall -D_THREAD_SAFE
CPPFLAGS = -I/usr/local/opt/freetype/include/freetype2
CXX = clang++
CXXFLAGS = -D_THREAD_SAFE
LDFLAGS = -L/usr/local/opt/freetype/lib
LIBS = -lfreetype -lbz2 -lz -lltdl -lm -lpthread
尝试加载 png 文件导致同样的错误。直接从命令行使用 gm
效果很好。
您的 Octave 和 gm 安装可能链接到不同的 GraphicsMagick 库,因此 gm -version
的输出可能不准确。您可能应该从 Octave 内部检查它,如下所示:
octave:1> imformats
Extension | isa | Info | Read | Write | Alpha | Description
----------+-----+------+------+-------+-------+------------
bmp | yes | yes | yes | yes | yes | Microsoft Windows bitmap image
cur | yes | yes | yes | no | yes | Microsoft Cursor Icon
gif | yes | yes | yes | yes | yes | CompuServe graphics interchange format
ico | yes | yes | yes | no | yes | Microsoft Icon
jbg | yes | yes | yes | yes | yes | Joint Bi-level Image experts Group interchange format
jbig | yes | yes | yes | yes | yes | Joint Bi-level Image experts Group interchange format
jpg, jpeg | yes | yes | yes | yes | yes | Joint Photographic Experts Group JFIF format
pbm | yes | yes | yes | yes | yes | Portable bitmap format (black/white)
pcx | yes | yes | yes | yes | yes | ZSoft IBM PC Paintbrush
pgm | yes | yes | yes | yes | yes | Portable graymap format (gray scale)
png | yes | yes | yes | yes | yes | Portable Network Graphics
pnm | yes | yes | yes | yes | yes | Portable anymap
ppm | yes | yes | yes | yes | yes | Portable pixmap format (color)
ras | yes | yes | yes | yes | yes | SUN Rasterfile
tga, tpic | yes | yes | yes | yes | yes | Truevision Targa image
tif, tiff | yes | yes | yes | yes | yes | Tagged Image File Format
xbm | yes | yes | yes | yes | yes | X Windows system bitmap (black/white)
xpm | yes | yes | yes | yes | yes | X Windows system pixmap (color)
xwd | yes | yes | yes | yes | yes | X Windows system window dump (color)
您还可以通过 ldd
检查 Octave 实际使用的库是什么(因为您使用的是 Mac,您可能没有 ldd
但 google 告诉我 otool -L
是 Mac 解决方案)。就我而言,我知道它们是相同的:
$ ldd /usr/local/lib/octave/5.0.0/liboctinterp.so | grep Magick
libGraphicsMagick++-Q16.so.12 => /lib/libGraphicsMagick++-Q16.so.12 (0x00007f858a896000)
libGraphicsMagick-Q16.so.3 => /lib/libGraphicsMagick-Q16.so.3 (0x00007f858a52e000)
$ ldd /usr/bin/gm | grep Magick
libGraphicsMagick-Q16.so.3 => /lib/libGraphicsMagick-Q16.so.3 (0x00007f5041f66000)
一旦您知道 Octave 为 GraphicsMagick 使用的实际库,您就可以检查该库是否链接到 libjpeg:
$ ldd /lib/libGraphicsMagick++-Q16.so.12 | grep jpeg
libjpeg.so.62 => /lib/x86_64-linux-gnu/libjpeg.so.62 (0x00007f63e910c000)
您也可以从八度配置中获得一些提示:
octave:1> __octave_config_info__.build_environment.MAGICK_CPPFLAGS
ans = -I/usr/include/GraphicsMagick
octave:2> __octave_config_info__.build_environment.MAGICK_LDFLAGS
ans =
octave:3> __octave_config_info__.build_environment.MAGICK_LIBS
ans = -lGraphicsMagick++ -lGraphicsMagick