Variables can be used to pass information to the ImageMagick code. The variables can come from a form or from some other part of the code; for instance the image size when using
<?php $size = getimagesize('sunflower.jpg');?>
The variables sometimes need to be isolated from the code and I use { and } for that.
<?php
$size = getimagesize('sunflower.jpg');
exec("convert -size {$size[0]}x{$size[1]} input_image.jpg -resize 100x100 output_image.jpg");
?>
If you have a long path I find it easyer to put the path into a variable.
<?php
$input_image = "folder1/folder2/input_image_12345.jpg";
exec("convert $input_image output_image.jpg");
?>