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.
This site has some interesting code to modify images and I ran the code by:
// Run the script exec("/FULL PATH TO AUTOTRIM/autotrim.sh zelda3_border2w.png fred.png 2>&1", $array); //Display any errors echo "<pre>"; echo print_r($array)."<br>"; echo "</pre>";
$cmd=" bash /FULL PATH TO AUTOTRIM/autotrim.sh zelda3_border2w.png fred.png"; exec($cmd,$result); if($result=="0") echo "sucess"; else echo"fail";
When I ran the code I recived an error:
/autotrim.sh: line 271: bc: command not found
bc is a calculator that is built into Unix/Linux.
I ran this code to get some information about the path for bc and it did not return anything so I assumed bc was not installed.
I contacted my hosts who installed it and the code worked OK.
echo "<pre>"; system('which bc',$path); print_r($path); echo "</pre>";
I was also told that I may have been able to install the bc binarys ( although I could not find them ) and use the path to those in the code. I did not need to try that so I do not know if it would have worked or not.