eZ Community » Blogs » Philippe VINCENT-ROYOL » Alternativ to ImageMagick

By

Alternativ to ImageMagick

Wednesday 24 October 2012 2:21:56 pm

  • Currently 5 out of 5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

GraphicsMagick is the swiss army knife of image processing. It provides a robust and efficient collection of tools and libraries which support reading, writing, and manipulating an image in over 88 major formats including important formats like DPX, GIF, JPEG, JPEG-2000, PNG, PDF, PNM, and TIFF.

Image processing is multi-threaded using OpenMP so that CPU-bound tasks scale linearly as processor cores are added. 

GraphicsMagick is originally derived from ImageMagick 5.5.2 as of November 2002 but has been completely independent of the ImageMagick project since then. 

Its time to install it and configure for eZ Publish ! Command line was for Debian 6 Squeeze, but you can easily "translate" to Redhat Os, Cent Os, Ubuntu etc.

Why Using GraphicsMagick ?

Better performances than ImageMagick. You could find some benchmark here : http://www.graphicsmagick.org/OpenMP.html and here http://www.graphicsmagick.org/benchmarks.html

 

Requirements

You need to install gcc and some dev librairies. So to resume :

apt-get install gcc make libpng12-dev libjpeg62-dev libjasper-dev

This command line will install librairies for PNG, JPEG and JPEG2000 files. You could add more librairies, please check here : http://www.graphicsmagick.org/README.html#add-on-libraries-programs

 

GraphicsMagick

Download GraphicsMagick's archive (http://sourceforge.net/projects/graphicsmagick/files/graphicsmagick/) I downloaded version 1.3.17. (Installation via apt-get have some issues with convert parameters)

Extract archive and install :

tar xvfz GraphicsMagick-1.3.17.tar.gz
cd GraphicsMagick-1.3.17
./configure
make
make install

Configure eZ Publish 4.X

Just create an image.ini.append.php file and inject those lines:

[ImageMagick]
ExecutablePath=/usr/local/bin/
Executable=gm convert

Purge cache and its works ! If not check debug file or add a test point (like a barbarian with a var_dump) on ./lib/ezimage/classes/ezimageshellhandler.php line 100

Full Filters example: (implement on settings/override/image.ini.append.php)

[ImageMagick]
IsEnabled=true
ExecutablePath=/usr/local/bin/
Executable=gm convert
Filters[]=vignette=-resize '%1x%2^' -gravity center -crop %1x%2+0+0 +repage
Filters[]=sharpen=-sharpen 0.5 
Filters[]=optimize=-strip
 
[vignette_682x224]
Reference=
Filters[]
Filters[]=optimize
Filters[]=vignette=682;224
Filters[]=sharpen=

On this example, i would like to resize to fill a box (width: 682px; height: 224px). I add an option, strip, to remove comment an other useless information on image. Apply a resize, center image and use a crop. It works with ImageMagick and GraphicsMagick.

Configure eZ Publish 5.x

You need to modify your ezpublish.yml (located on <ez5_root>/ezpublish/config/ezpublish.yml) and add this:

imagemagick:
    enabled: true
    path: /path/to/gm convert

Be careful: you need to apply this patch https://github.com/ezsystems/ezp-next/commit/eb666fc6bdc34e82c3a0898cbb7c7e69b459b82b

Thanks to Jerome with his usefull advice :)

Cheers.

 

Extra Tips : Install on Mac OSX (Mountain) Lion

You need to download source file :

ftp://ftp.graphicsmagick.org/pub/GraphicsMagick/GraphicsMagick-LATEST.tar.bz2

http://sourceforge.net/projects/libpng/files/libpng14/

http://www.ijg.org/files/jpegsrc.v8d.tar.gz

After that, uncompress each file and run those command lines

# download libpng 1.4.x (1.5 didn't work yet with GraphicsMagick 1.3.12)
./configure --prefix=/opt/local && make && make install

# download libjpeg
./configure --prefix=/opt/local && make && make install

# download GraphicsMagick
CFLAGS=-I/opt/local/include LDFLAGS=-L/opt/local/lib ./configure --prefix=/opt/local --disable-openmp --disable-openmp-slow && make && make install

Don't forget it needed, to add /opt/local to your path. (Edit ~/.bash_profile) and add :

export PATH="/opt/local/bin:$PATH"

Save and reload bash profile via

source ~/.bash_profile
Proudly Developed with from