Editing GraphicsMagick

Jump to navigation Jump to search
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 1: Line 1:
Octave will use [http://www.graphicsmagick.org/ 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.
Octave will use [http://www.graphicsmagick.org/ GraphicsMagick] for reading and writing your images (not plots, only if you are actually doing image processing). This means that the GraphicsMagick configuration you have on you system will limit what your Octave installation can do. Most systems will have it onn  their repositories. Unfortunately, their configuration is not always the best for image analysis as it limits reading of images to 8-bit.


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.
 
== Building ==
See below for the reasoning behind each flag and tracking dependencies. Once done, the following commands should work to build GraphicsMagick.
<pre>
<pre>
./configure --with-quantum-depth=16 --enable-shared --disable-static --with-magick-plus-plus=yes
./configure --with-quantum-depth=32 --enable-shared --disable-static --with-perl=yes --with-magick-plus-plus=yes
make
make
make check
make check
sudo make install
make install
</pre>
</pre>
{{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.}}


== Quantum depth ==
== Quantum depth ==
The most common problem is the following warning when using {{Codeline|imread()}} or {{Codeline|imwrite()}}:
The most common problem is the following warning when using {{Codeline|imread()}}:
<pre>warning: your version of GraphicsMagick limits images to <N> bits per pixel</pre>
...where {{codeline|N}} can be 8, 16 or 32.
For instance:
<pre>warning: your version of GraphicsMagick limits images to 8 bits per pixel</pre>
<pre>warning: your version of GraphicsMagick limits images to 8 bits per pixel</pre>
This warning means that GraphicsMagick was compiled with {{Codeline|--with-quantum-depth <N>}}, which implements that limitation. The [http://www.graphicsmagick.org/INSTALL-unix.html INSTALL-unix page] of GraphicsMagick documentation explains the rationale of this option.
The reason for this is that GraphicsMagick was compiled with {{Codeline|--with-quantum-depth 8}}. Possible values are 8, 16 or 32, each implememnting that limitation. See the {{Path|INSTALL}} [http://graphicsmagick.hg.sourceforge.net/hgweb/graphicsmagick/graphicsmagick/file/tip/INSTALL-unix.txt#l429 file] on GraphicsMagick sourcefor an explanantion of this. There has bugs reported requesting package maintainers to compile it with higher values. You should not create a new bug, instead leave a comment on the already open bugs: [http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=557879 Debian], [https://bugs.launchpad.net/ubuntu/+source/graphicsmagick/+bug/696215 Ubuntu].
 
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 [http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=557879 Debian], [https://bugs.launchpad.net/ubuntu/+source/graphicsmagick/+bug/696215 Ubuntu], and [https://bugzilla.redhat.com/show_bug.cgi?id=996411 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 [https://savannah.gnu.org/bugs/?45662 relevant bug report], if you know it won't affect your code. To do this, add the following command to your script:
 
<pre>warning('off', 'Octave:GraphicsMagic-Quantum-Depth');</pre>
 
The proper solution is to compile GraphicsMagick yourself, to pass the desired value to {{codeline|--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.}}
As versions with higher values are not available on the repositories, the solution is to compile it. Octave needs then to be recompiled to use the freshly compiled Magick++ library.


== Magick++ ==
== Magick++ ==
Line 37: Line 27:
== Dependencies ==
== Dependencies ==
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.
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.
To start with you will obviously need the following
* a C compiler such as gcc
* a C++ compiler such as g++
* make
=== Main dependencies ===
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.


{| class="wikitable"
{| class="wikitable"
|-
|-
! Dependency        !! Debian Wheezy                    !! Ubuntu Precise   !! OpenSUSE 13.2
! Dependency        !! Debian Wheezy                    !! Ubuntu Precise
|-
|-
| BZLIB            || libbz2-dev                      || libbz2-dev       || libbz2-devel
| BZLIB            || libbz2-dev                      || libbz2-dev
|-
|-
| FlashPIX          ||                                 ||                  ||
| dcraw            || dcraw                            || dcraw
|-
|-
| FreeType 2.0      || libfreetype6-dev                || libfreetype6-dev  || freetype2-devel
| dot              || graphviz                        || graphviz
|-
|-
| Ghostscript      || ghostscript                      || ghostscript      ||
| fig2dev          || transfig                        || transfig
|-
|-
| Ghostscript-fonts || gsfonts                          || gsfonts          ||
| FlashPIX          ||                                 ||
|-
|-
| JBIG              || libjbig-dev                     ||                   || libjbig-devel
| FreeType 2.0      || libfreetype6-dev                 || libfreetype6-dev
|-
|-
| JPEG v1          || libjpeg8-dev                    || libjpeg-dev      || libjpeg62-devel
| Ghostscript      || ghostscript                      || ghostscript
|-
|-
| JPEG-2000        || libjasper-dev                    || libjasper-dev    || libjasper-devel
| Ghostscript-fonts || gsfonts                          || gsfonts
|-
|-
| LCMS v2           || liblcms2-dev                    || liblcms2-dev      || liblcms2-devel
| gnuplot           || gnuplot                          || gnuplot
|-
|-
| ltdl              || libltdl-dev                      || libltdl-dev      || libtool
| hp2xx            || hp2xx                            || hp2xx
|-
|-
| LZMA              || liblzma-dev                      || liblzma-dev      || xz-devel
| html2ps          || html2ps                          || html2ps
|-
|-
| PNG              || libpng12-dev                     || libpng12-dev      || libpng12-devel
| JBIG              || libjbig-dev                     ||
|-
|-
| TIFF              || libtiff5-dev                    || libtiff5-dev     || libtiff-devel
| JPEG v1          || libjpeg8-dev                    || libjpeg-dev
|-
|-
| WEBPD            || libwebp-dev                     ||                  || libwebp-devel
| JPEG-2000        || libjasper-dev                   || libjasper-dev
|-
|-
| WMF              || libwmf-dev                       || libwmf-dev       || libwmf-devel
| LCMS v2          || liblcms2-dev                     || liblcms2-dev
|-
|-
| X11              || libx11-dev libxext-dev libsm-dev ||                  ||
| ltdl              || libltdl-dev                     || libltdl-dev
|-
|-
| XML              || libxml2-dev                      || libxml2-dev       || libxml2-devel
| LZMA              || liblzma-dev                      || liblzma-dev
|-
|-
| ZLIB              || zlib1g-dev                       || zlib1g-dev       || zlib-devel
| PNG              || libpng12-dev                     || libpng12-dev
|-
|-
|}
| ra_ppm            || radiance                        || radiance
 
{{Note|the following libraries are not listed because:
* Trio is only needed/useful on certain archaic systems which lack secure vsnprintf variants.
* DPS has been [http://dps.sourceforge.net/ deprecated] and should not be used.
* Ghostscript library support is not recommended by GraphicsMagick on Unix type systems. Read their README.txt file.
* there are both v1 and v2 LCMSlibraries but GraphicsMagick only needs one of them.
}}
 
=== Other dependencies ===
These other dependendies are easily added via a user-editable text file after building and installation. They are much more specific and most users will have no need for them.
 
{| class="wikitable"
|-
|-
! Dependency        !! Debian Wheezy                    !! Ubuntu Precise
| scanimage        || sane-utils                      || sane-utils
|-
| dcraw            || dcraw                            || dcraw
|-
| dvips            || texlive-base                    || texlive-base
|-
| dot              || graphviz                        || graphviz
|-
| fig2dev          || transfig                        || transfig
|-
| gnuplot          || gnuplot                          || gnuplot
|-
| hp2xx            || hp2xx                            || hp2xx
|-
| html2ps          || html2ps                          || html2ps
|-
| lp                || cups-client                      || cups-client
|-
| lpr              || cups-bsd                        || cups-bsd
|-
|-
| mpeg2decode      ||                                 ||
| TIFF              || libtiff5-dev                    || libtiff5-dev
|-
|-
| mpeg2encode      ||                                  ||
| TRIO              ||                                  ||  
|-
|-
| pgpv              || pgpgpg                          || pgpgpg
| WMF              || libwmf-dev                      || libwmf-dev
|-
|-
| povray            ||                                 ||
| X11              || libx11-dev libxext-dev libsm-dev ||  
|-
|-
| ra_ppm            || radiance                        || radiance
| XML              || libxml2-dev                      || libxml2-dev
|-
|-
| rawtorle          ||                                 ||
| ZLIB              || zlib1g-dev                       || zlib1g-dev
|-
| scanimage        || sane-utils                       || sane-utils
|-
|-
|}
|}
You will also need to install g++ and gcc (or alternatives).
{{Note|DPS has been [http://dps.sourceforge.net/ deprecated] and should not be used hence why is not on the list.}}
{{Note|Ghostscript library support is not recommended by GraphicsMagick hence why is not on the list.}}
{{Note|there are both LCMS v2 and v1 but GraphicsMagick only needs one of them.}}
Please note that all contributions to Octave may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see Octave:Copyrights for details). Do not submit copyrighted work without permission!

To edit this page, please answer the question that appears below (more info):

Cancel Editing help (opens in new window)

Templates used on this page: