Overview
GraphicsMagick provides a comprehensive collection of utilities, programming interfaces, and GUIs, to support file format conversion, image processing, and 2D vector rendering. View more information at the following link:
Preparing the environment
- Log into your server via SSH.
- Make sure you're in your user's main directory, not your domain's directory.
- Create a build directory where all the required tools are downloaded, configured, and then compiled:
[server]$ mkdir build
- Create a local directory where all the required tools are deployed:
[server]$ mkdir local
Installing GraphicsMagick
Once you have created the /build and /local directories, proceed with the following commands. This example uses version 1.3.21.
[server]$ cd build [server]$ wget "ftp://ftp.graphicsmagick.org/pub/GraphicsMagick/GraphicsMagick-LATEST.tar.gz" [server]$ tar zxvf GraphicsMagick-LATEST.tar.gz [server]$ cd GraphicsMagick-1.3.21 [server]$ ./configure --prefix=$HOME/local --enable-shared --enable-symbol-prefix [server]$ make [server]$ make install
If everything runs smoothly, up-to-date GraphicsMagick binaries, libs collection, documentation and so on are available in your local directory (and subdirectory).
Start using this local directory by running the following command:
[server]$ export PATH=$HOME/local/bin:$PATH
Building the gmagick PHP module
- Navigate to your /build directory.
[server]$ cd ~/build
- Visit pecl.php.net/package/gmagick and choose the version you wish to use.
- Run the following commands based on the version you're using. This example uses 1.1.7RC3.
[server]$ wget "https://pecl.php.net/get/gmagick-1.1.7RC3.tgz" [server]$ tar zxvf gmagick-1.1.7RC3.tgz [server]$ cd gmagick-1.1.7RC3
- Run the following to ensure that imagick compiles more smoothly. Change the phpize version to the actual PHP version you need to use. View the PHP versions article for details:
[server]$ /usr/local/php72/bin/phpize [server]$ export PKG_CONFIG_PATH=$HOME/local/lib/pkgconfig [server]$ ./configure --prefix=$HOME/local --with-gmagick=$HOME/local --with-php-config=/usr/local/php72/bin/php-config [server]$ make
You may see a few compilation warnings. You can safely ignore these. Look for the following which ensures successful installation:
Libraries have been installed in:
/home/username/build/gmagick-1.1.7RC3/modules
Configuring PHP to use this extension
Visit the PHP.ini article for details on how to create a phprc file.
In this example the domain is running under PHP 7.2. So your phprc file would be in this directory:
Run the following to create your /extensions directory, copy the module and add it to the phprc file:
[server]$ cd ~/.php/7.2 [server]$ mkdir extensions [server]$ cp ~/build/gmagick-1.1.7RC3/modules/gmagick.so extensions [server]$ echo "extension = ~/.php/7.2/extensions/gmagick.so" >> phprc