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.
Set a region in which subsequent operations apply.
$cmd = "$input -region 140x120+50+20 -colorspace Gray"; exec("convert $cmd region_gray.jpg");
( Supported in ImageMagick 6 and 7.0.2-6 and above )
Reduce the number of colors in an image to the colors used by this image.
$cmd = "$input +dither ". " -colors 24 -remap $input3"; exec("convert $cmd remap.jpg");
( Using the orange red gradiant to change the colours within the hibiscus photo )
Adjust the canvas and offset information of the image.
$cmd = "$input -crop 133x140+80+25 +repage"; exec("convert $cmd repage.jpg");
( Use +repage to completely remove/reset the virtual canvas meta-data from the images. )
Resample image to specified horizontal and vertical resolution.
$cmd = "$input -resample 30"; exec("convert $cmd resample.jpg");
Resize the image and leave EXIF data etc.
See resize( Resize and thumbnail have the same effect but thumbnail strips the EXIF data etc. but leaves the colour profile on later versions. You can specify the filter to use - see filter. )
Settings remain in effect until parenthesis boundary.
More information to follow.Reverse the order of images in the current image list.
$cmd = "$input1 $input -reverse -gravity center". " -composite "; exec("convert $cmd reverse.jpg");
Rotate the image
$cmd = "$input -background transparent -rotate 30"; exec("convert $cmd rotate_30.png");
Scale image using pixel sampling.
$cmd = "$input -sample 100x100"; exec("convert $cmd sample.jpg");
Different type of resizing an image
$cmd = "$input -scale 133x100"; exec("convert $cmd scale.jpg");
( The -scale option uses a simpler, faster algorithm than -resize, and it ignores the -filter setting if one is present. Offsets, if present in the geometry string, are ignored, and the -gravity option has no effect. )