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.
There are some things you need to know before starting:
- ImageMagick is an external program ( not built into php ) and needs "calling" from the php code.
- Is ImageMagick installed on your server use this to check
- The path to ImageMagick on the server use this to check
- ImageMagick works on the server "Shell" and should not work in "Safe mode".
- Some methods may not work depending what version of ImageMagick you have installed use this to check
- You want to keep all your exec line on one line but if you need to have a new line use \ at the end of the line. You will need to escape the \ with another \ e.g. \\
- You can use variables for parts of the code See this page.
- You will need to CHMOD the folders the images are saved to 777
NOTE: If your server is running phpsuexec you do not need to CHMOD to 777 but to 755 . If you do CHMOD to 777 in the case of phpsuexec you will get an "500 Internal server error".
- Most of the code can easily be bult into forms etc.
- My server has just been updated to version 6.3.5 and that is what the examples are based on. To get certain things working like PDF and the text you need the Ghostscript installed as well
- If you are using a path to a file e.g. ../folder/image.jpg it will could break the code but if you put $name = '../folder/image.jpg' and use $name in the code instead it should work.
- You will need to escape any " and ( if you use them, putting a \ in front should work e.g. \" and \( code \)
- You must write the code correctly e.g. if you write - pointsize instead of -pointsize the code will fail.