Snippets - Utilities

Snippets index page

NOTE: Most of the IM snippets have been tested on IM version 6.3.5 There may be some differences if you are using the code on other versions.

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

  1. <?php
  2. // Run the script
  3. exec("/FULL PATH TO SCRIPT/autotrim.sh input.png output.png 2>&1"$array); 
  4. //Display any errors
  5. echo "<br>".print_r($array)."<br>"
  6. echo "</pre>";
  7. //
  8. /* When I ran the code I recived an error:
  9. /autotrim.sh: line 271: bc: command not found
  10. bc is a calculator that is built into Unix/Linux.
  11. 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.
  12. I contacted my hosts who installed it and the code worked OK.
  13. */
  14. echo "<pre>";
  15. system(which bc,$path); print_r($path); 
  16. echo "</pre>";
  17. ?>
  18. //Alternative method using "back ticks"
  19. <?php
  20. `/FULL PATH TO SCRIPT/texteffect.sh -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`; 
  21.     ?>
http://www.fmwconcepts.com/imagemagick/index.php

For more examples and information check out the main Imagemagick section.

Batch file View

Fonts installed View

Fonts Installed view View

Gravity option View

http image source View

Image information View

New image size in variable View

Path - find automaticly View

Path to Imagemagick View

Setup Information View

Shell script View

Variables in the code View

Version of Imagemagick installed View

Writing IM code View