Honesty Rocks! truth rules.

How To Find And Test Imagemagick Using Php

HOME      >>       Programming


One of the powerful graphics manipulation programs that Xisto provides is home page in the right column:


Our Free Web Hosting offer :-


ImageMagick Support

I have not seen ImageMagick mentioned in any other free, or nearly free, Web service. This is one of the things that attracted me to Xisto. ImageMagick is very powerful. As its website describes its capabilities:

  • ImageMagick® is a software suite to create, edit, and compose bitmap images.
  • It can read, convert and write images in a variety of formats (over 100).
  • ImageMagick is free software delivered as a ready-to-run binary distribution or as source code that you may freely use, copy, modify, and distribute. Its license is compatible with the GPL. It runs on all major operating systems.

Personally, I am interested in it because it is a necessary tool in MediaWiki. If one wishes to typeset mathematical equations in MediaWiki (as is done in Wikipedia), ImageMagick is a required component of the extension that provides this capability.


A while ago, I had trouble finding it on gamma.xisto.com. This tutorial shows how to test for it, and verify that it is functional. Since the primary focus of Xisto is web hosting, the tutorial is in PHP. This illustrates how ImageMagick can be used in any website that uses PHP scripts.


Here is a PHP program to test for the presence of ImageMagick, and print out its version number.

Create a file in your public_html folder or a subfolder, paste this text into it, and name it something like test4im.php where the ".php" ending is necessary to get the PHP interpreter to process it. Point a browser at this file (e.g. http://forums.xisto.com/no_longer_exists/ website]/test4im.php). If you have access to "convert," you will get a return code of 0 plus two or three lines of text, reporting the version and location of ImageMagick. Strictly speaking, you do not need to create the alist function since it is only called once here, but if you wish to test other things, it will save repetitive typing. (This is, after all, a tutorial on PHP.)


There is one more important step to make sure you can use ImageMagick. Almost everything you do with it will involve creating a file. Therefore, you need to be sure you can give it an argument that correctly identifies the location you want, and provides the appropriate permissions. Suppose you want the output in a folder called "temp" in your public_html folder. First you must create the folder and set its permissions. Use cPanel to create a folder "public_html/temp". Use the "permissions" tool to set "temp" to "777" which means anyone (including the "user" that runs an html task) can write to the "temp" folder. Now add the following two lines to your "test4im.php" program, at the location of the next-to-last line above.

The first line creates an ImageMagick logo image and stores it in the "temp" folder. The second prints the return code. Save this modified file and reload the browser page. If you got a version number before, and now get a non-zero return code, you probably didn't create the "temp" folder in the right place, or set its permissions correctly. If you get a return code of 0, examine the "imlogo.gif" file using the "View" tool in the cPanel File Manager. You should see this: Posted Image


Thanks a lot docduke, i just follow your tutorial and test your code and every thing works perfectly.


BTW, this is the first time that i use Imagemagick and to be honest it is awesome, i don't know that with it you can do a lot of incredible things with images.


Best regards,


ImageMagick is used by 4gallery photogallery. When you set up your site, it asks you where imagemagick is installed in your server. If not, you have to use gl libraries, which generally use too much memory.


Thank you very much for your kindly advice.

But it seemed to me that I can NOT see your last image you pasted.



Hi docduke

I am getting the following error message


Version return code is 4

  • Invalid drive specification.

Do you know why this error?

I am using IIS8.1 windows


Invalid drive specification.

Do you know why this error?

Seems rather self-explanatory : you are pointing to a file on a drive which is not the one accessed by IIS8?