Rubblewebs

THESE CODES ARE PROVIDED FOR AN EXAMPLE OF HOW TO USE IMAGEMAGICK WITH PHP. CARE SHOULD BE TAKEN WHEN ACCEPTING USER INPUT.

I TAKE NO RESPONSABILTY FOR ANY PROBLEMS THAT MAY OCCURE WHEN USING ANY OF THIS CODE.

IT IS UP TO YOU TO SECURE THE CODE AND VALIDATE USER INPUT.

Installation notes - Linux/Unix:

Linux version with a dedicated rpm file

  1. Download and run the latest binary release for your version of linux.
  2. Extract the rpm file to a folder on your PC.
  3. Run the config file in folder from step 2 ( you need to be connected to the internet as some extra files may need to be downloaded ).
  4. Confirm it is working by running in the terminal: convert -version
  5. Run your code like this in the terminal : convert full_path_to_input.jpg -thumbnail 100x100 full_path_to_output.jpg

Install from source code ( works for all Linux distrubitions )

  1. Download ImageMagick source code ( usually it's a .tar.gz ) to the server's temporary directory ( for example /tmp ). cd /tmp
    enter /tmp folder
    wget ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick-6.3.5-9.tar.gz
  2. Unpack the archive
    tar -xvzf ImageMagick.tar.gz
  3. Enter the ImageMagick source code directory
    cd ImageMagick-6.3.5
  4. install ImageMagick
    ./configure
    make
    make install

Alternative instructions

If the default RPM's can not be used the next best things is to build RPM's for your system using the .src.rpm download.

Superuser (root) priveleges are not needed to create the binary RPM's from the source RPM's, although it requires a little trick to do this.

Instructions for this method

This is preferable as removing a direct binary installation is not easy and you could end up with two versions of IM installed, causing all sorts of unexpected problems.

To install GhostScript

  1. Download Ghostscript source code ( usually it's a .tar.gz ) to the server's temporary directory ( for example /tmp ).
    cd /tmp
    enter /tmp folder
  2. Unpack the archive
    tar -xvzf ghostscript-8.60.tar.gz
  3. Enter the Ghostscript source code directory
    cd ghostscript-8.60
  4. install ghostscript
    ./configure
    make
    make install

To install fonts

  1. Downloaded archive with base fonts:
    wget http://downloads.sourceforge.net/ghostscript/ghostscript-fonts-std-8.11.tar.gz
  2. Go to GhostScript directory:
    cd /usr/local/share/ghostscript/
  3. Unpacked fonts:
    tar -xvzf ghostscript-fonts-std-8.11.tar.gz

    The path to the fonts will be: /usr/local/share/ghostscript/fonts/
    Extra fonts can be installed using the method above.