The new "imlib" PHP-extension is much nicer than running "convert" commands (convert is part of ImageMagicsk).
See http://rpms.arvin.dk/php/install-ready/i686/?describe=php-imlib#descs
If php-imlib is not an option, then see documentation for ImageMagick (look at its website). Also, see the PHP manual about the back-tick operator and functions like escape_shell_args().
Also, note that it's sometime useful to add the following to the execution command when executing external programs:
......... 2>&1
The "2>&1" means that error messages will be treated as normal program output.