Back to the snippets index

Shell script ( Anthony 15/6/2008 )

Using a shell script with php and IM. Download the script and upload it to your server.
Change the permissions to 755 on the script.
Write your php code like this using the full path to the script.

IM code:

// Run the script
exec("/FULL PATH TO SCRIPT/ input.png output.png 2>&1", $array); 
//Display any errors
echo "<br>".print_r($array)."<br>"; 
echo "</pre>";
/* When I ran the code I recived an error:
/ line 271: bc: command not found
bc is a calculator that is built into Unix/Linux.
I ran the code below 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);
echo "</pre>";
//Alternative method using "back ticks"
`/FULL PATH TO SCRIPT/ -t "Anthony" -s glow -e normal -f verdana.ttf -p 48 -c skyblue -b white -o skyblue -l 1 -m 10 -g blue back_tick.png`; 

Link for more information

Batch file - windows server
Fonts installed
Fonts Installed view
Gravity option
http image source
Image information
New image size in variable
Path - find automaticaly
Path to Imagemagick
Setup Information
Shell script
Variables in the code
Version of Imagemagick installed
Writing IM code