Rubblewebs

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.

Imagemagick operators page 15

Regard warnings

Pay attention to warning messages.

More information to follow.

Region

Set a region in which subsequent operations apply.

Region example

$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 )

Remap

Reduce the number of colors in an image to the colors used by this image.

Remap example

$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 )

Remote

Perform a remote operation.

More information to follow.

Render

Render vector operations.

Another Render example

Repage

Adjust the canvas and offset information of the image.

Repage example

$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

Resample image to specified horizontal and vertical resolution.

Resample example

$cmd = "$input -resample 30"; 
exec("convert $cmd resample.jpg");

Resize

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. )

Respect parenthases

Settings remain in effect until parenthesis boundary.

More information to follow.

Reverse

Reverse the order of images in the current image list.

Reverse example

$cmd = "$input1 $input -reverse -gravity center". 
" -composite ";  
exec("convert $cmd reverse.jpg");

Roll

Roll example

$cmd = "$input -roll +50+0"; 
exec("convert $cmd roll.jpg");

Rotate

Rotate the image

Rotate example

$cmd = "$input -background transparent -rotate 30"; 
exec("convert $cmd rotate_30.png");

Sample

Scale image using pixel sampling.

Sample example

$cmd = "$input -sample 100x100"; 
exec("convert $cmd sample.jpg");

Scale

Different type of resizing an image

Scale example

$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. )