Install ImageMagick + Os X + Intel Compiler + OpenMP
Exploit as much as possible the ImageMagick library has important consequences in the overall performance of its algorithms. The OpenMP threading paradigm is available in ImageMagick to boost some algorithms.
This tutorial show you how to :
configure the ImageMagick installation with intel compiler
resolve macports issue on OsX 10.9
use ImageMagick with XCode 5
The software requirements to follow this tutorial are the following:
Let's start with the basic steps.
- We have to install the third-party software (or delegate) for ImageMagick.
sudo port -v install librsvg sudo port -v install graphviz +gs +wmf +jbig +jpeg2 +lcms sudo port -v install jpeg, tiff, ffmpeg
Download the last ImageMagick source code.
Initialize the environment for the intel compiler if not yet done:
source /opt/intel/bin/compilervars.sh intel64
Macport conflict issue
If you take a look to the jpeg library, you could keep a conflict like this:
$port info jpeg jpeg @9a_1 (graphics) Variants: universal Description: This package contains C software to implement JPEG image encoding, decoding, and transcoding. This software implements JPEG baseline, extended-sequential, and progressive compression processes. Homepage: http://www.ijg.org/ Conflicts with: libjpeg-turbo, mozjpeg Platforms: darwin, freebsd, sunos License: IJG
The conflit disallow the ImageMagick's configure script to find the right jpeg delegate, and also all the related jpeg libraries dependencies like tiff.
The way to avoid macport troubles is specify your choice library for jpeg by: LDFLAGS=-L/opt/local/lib -ljpeg
Two options for the intel compiler will be enough: -fopenmp -fast
Now you can run:
$./configure --prefix="/opt/local" "CC=icc" "CFLAGS=-fopenmp -fast" "CXX=icpc" "CXXFLAGS=-fopenmp -fast" "LDFLAGS=-L/opt/local/lib -ljpeg" --with-quantum-depth=16 --disable-dependency-tracking --with-x=yes --x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib/ --without-perl --enable-shared=yes --enable-static=yes
Followed by make and sudo make install
If all goes well, you should see the OpenMP feature
$convert --version Version: ImageMagick 6.8.9-3 Q16 x86_64 2014-06-18 http://www.imagemagick.org Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC Features: DPC OpenMP Delegates: bzlib fontconfig freetype jbig jng jpeg lcms lzma pangocairo png tiff webp x xml zlib
A simple resize test:
convert image.jpg -resize 64x64 resize_image.jpg
If the convert binary works fine, maybe you are ready to integrate the ImageMagick libraries into your application.
Use ImageMagick with XCode 5
As usual, to integrate ImageMagick or any library within your application, you have to define the paths for library and headers. Lets take a look with XCode 5.
To resolve links:
Project Navigator -> Select your Target -> Build Settings -> Linking -> Other Linker FLags
Add these strings: -L/opt/local/lib , -lMagickCore-6.Q16
You may want add the Wand (-lMagickWand-6.Q16) and C++ (-lMagick++-6.Q16) library as well.
To resolve headers:
Project Navigator -> Select your Target -> Build Settings -> Search Paths -> Header Search Paths
Add the string /opt/local/include/ImageMagick-6/
You are finally ready to play with ImageMagick!