GraphicsMagick

Octave will use GraphicsMagick for reading and writing your images (not for plots, only used for image processing). This means that the GraphicsMagick configuration you have on you system will determine what your Octave installation can do. Most systems will have it on their own repositories. Unfortunately, their configuration is not always the best for image analysis as it can limit the bit depth when reading and writing of images.

To solve the problem, GraphicsMagick needs to be rebuilt with the appropriate settings. See below for tracking dependencies and the reasoning behind each flag. Once done, the following commands should work to build GraphicsMagick.

Note: if after the build, you get "error while loading shared libraries: libGraphicsMagick.so.3: cannot open shared object file: No such file or directory" you need to run ldconfig. For security and performance reasons, Linux maintains a cache of the shared libraries installed in "approved" locations and this command will update it.

Contents

The most common problem is the following warning when using imread() or imwrite():

warning: your version of GraphicsMagick limits images to <N> bits per pixel

...where N can be 8, 16 or 32.
For instance:

warning: your version of GraphicsMagick limits images to 8 bits per pixel

This warning means that GraphicsMagick was compiled with --with-quantum-depth <N>, which implements that limitation. The INSTALL-unix page of GraphicsMagick documentation explains the rationale of this option.

There are several bug reports requesting package maintainers to compile GraphicsMagick with higher values. You should not create a new bug; instead look for open bugs for your system, and leave a comment there. For convenience, here are the links for the bugs reported against Debian, Ubuntu, and Fedora.

As versions with higher values are not available on the repositories, there are two ways to address this. The easiest is to suppress the warning, as suggested in the relevant bug report, if you know it won't affect your code. To do this, add the following command to your script:

warning('off', 'Octave:GraphicsMagic-Quantum-Depth');

The proper solution is to compile GraphicsMagick yourself, to pass the desired value to --with-quantum-depth. You will also need to recompile Octave to use the freshly compiled Magick++ library.

Warning: Increasing quantum depth may have a dramatic increase in memory usage. If you use QuantumDepth 32, all images will be read with that precision, even if they were saved with 8bit. This means that a 100MB 8bit image will temporarily take 400MB memory, or more if the image was compressed (and they usually are), before Octave resizes it back down to 100MB. Because of this, because images using 32 bit integers are rare, and because GraphicsMagick does not handle floating point, it's recommended to use QuantumDepth of 16.

Magick++ is the C++ application programming interface to GraphicsMagick. This is what Octave uses so you will need this when compiling GraphicsMagick. This will be enabled by default but if you don't have a C++ compiler installed (such as g++) GraphicsMagick will build just fine without a warning, just a small note during the run of configure.

The default is to disable shared libraries but that won't work with Octave. You will need to pass the --enable-shared option. If you do not, Octave will give the following warning when running configure:

GraphicsMagick++ library fails tests. The imread function for reading image files will not be fully functional.

Compiling from source means tracking the dependencies yourself which may be a kind of painful. There's no wiki for GraphicsMagick so the following table hopes to makes things easier. Note however that this is the list of all dependencies and suggestions. For Octave purposes only, you definetely will not need all of these.

These are the ones which support being enabled or disabled via the configure script options and are shown in the summary status at the end of the configure script run. You will need them at compile time.

Dependency

Debian Wheezy

Ubuntu Precise

OpenSUSE 13.2

BZLIB

libbz2-dev

libbz2-dev

libbz2-devel

FlashPIX

FreeType 2.0

libfreetype6-dev

libfreetype6-dev

freetype2-devel

Ghostscript

ghostscript

ghostscript

Ghostscript-fonts

gsfonts

gsfonts

JBIG

libjbig-dev

libjbig-devel

JPEG v1

libjpeg8-dev

libjpeg-dev

libjpeg62-devel

JPEG-2000

libjasper-dev

libjasper-dev

libjasper-devel

LCMS v2

liblcms2-dev

liblcms2-dev

liblcms2-devel

ltdl

libltdl-dev

libltdl-dev

libtool

LZMA

liblzma-dev

liblzma-dev

xz-devel

PNG

libpng12-dev

libpng12-dev

libpng12-devel

TIFF

libtiff5-dev

libtiff5-dev

libtiff-devel

WEBPD

libwebp-dev

libwebp-devel

WMF

libwmf-dev

libwmf-dev

libwmf-devel

X11

libx11-dev libxext-dev libsm-dev

XML

libxml2-dev

libxml2-dev

libxml2-devel

ZLIB

zlib1g-dev

zlib1g-dev

zlib-devel

Note: the following libraries are not listed because:

Trio is only needed/useful on certain archaic systems which lack secure vsnprintf variants.