The magick package provide a modern and simple toolkit for image processing in R. It wraps the ImageMagick STL which is the most comprehensive open-source image processing library available today.


When installing the package we have error message,

> install.packages("magick")
Installing package into ‘/rds/user/jhz22/hpc-work/R'
(as ‘lib' is unspecified)
trying URL ''
Content type 'application/x-gzip' length 4813079 bytes (4.6 MB)
downloaded 4.6 MB

* installing *source* package ‘magick' ...
** package ‘magick' successfully unpacked and MD5 sums checked
** using staged installation
Package Magick++ was not found in the pkg-config search path.
Perhaps you should add the directory containing `Magick++.pc'
to the PKG_CONFIG_PATH environment variable
No package 'Magick++' found
Using PKG_LIBS=-lMagick++-6.Q16
--------------------------- [ANTICONF] --------------------------------
Configuration failed to find the Magick++ library. Try installing:
 - deb: libmagick++-dev (Debian, Ubuntu)
 - rpm: ImageMagick-c++-devel (Fedora, CentOS, RHEL)
 - csw: imagemagick_dev (Solaris)
 - brew imagemagick@6 (MacOS)
For Ubuntu versions Trusty (14.04) and Xenial (16.04) use our PPA:
   sudo add-apt-repository -y ppa:cran/imagemagick
   sudo apt-get update
   sudo apt-get install -y libmagick++-dev
If Magick++ is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a Magick++.pc file. If pkg-config
is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
-------------------------- [ERROR MESSAGE] ---------------------------
<stdin>:1:22: fatal error: Magick++.h: No such file or directory
compilation terminated.
ERROR: configuration failed for package ‘magick'
* removing ‘/rds/user/jhz22/hpc-work/R/magick'

The downloaded source packages are in
Warning message:
In install.packages("magick") :
  installation of package ‘magick' had non-zero exit status

Although which convert and which display both point to /usr/bin, it turned out that the required ImageMick needs to be loaded as follows,

module load image-magick-7.0.5-9-gcc-5.4.0-d4lemcc


It turned out gcc/6 is required for module image-magick-7.0.5-9-gcc-5.4.0-d4lemcc, coupling with C++11 via ~/.R/Makevars.

CXX=g++ -std=gnu++11
PKG_CXXFLAGS= -std=c++11
CFLAGS = -std=c99 -I/usr/include -g -O2 -Wall -pedantic -mtune=native -Wno-ignored-attributes -Wno-deprecated-declarations -Wno-parentheses -Wimplicit-function-declaration
CXXFLAGS = -std=c++11

The setup is appropriate for module ceuadmin/ImageMagick/7.1.1-31 with src/Makevars and a disabled configure,

PKG_CPPFLAGS=-fopenmp -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16 -DMAGICKCORE_CHANNEL_MASK_DEPTH=32 -I/usr/local/Cluster-Apps/ceuadmin/ImageMagick/7.1.1-31/include/ImageMagick-7
PKG_LIBS=-L/usr/local/Cluster-Apps/ceuadmin/ImageMagick/7.1.1-31/lib -lm -lMagick++-7.Q16HDRI -lMagickWand-7.Q16HDRI -lMagickCore-7.Q16HDRI


	rm -f $(SHLIB) $(OBJECTS)