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 2

Auto gamma

Automagically adjust gamma level of image.

Auto gamma example

$cmd = "$input -auto-gamma"; 
exec("convert $cmd auto_gamma.jpg");

Auto level

Automagically adjust color levels of image.

Auto level example

$cmd = "$input -auto-level"; 
exec("convert $cmd auto_level.jpg");

Auto orient

Automagically orient (rotate) an image created by a digital camera.

Auto orient example

$cmd = "$input -auto-orient"; 
exec("convert $cmd auto_orient.jpg");

( Will only work if the camera saves the oriantation to the EXIF data. )

Average

Average a set of images.

Average example

$cmd = "$input blue-shift.jpg auto_gamma.jpg -average"; 
exec("convert $cmd average.jpg");

Backdrop

Display the image centered on a backdrop.

Not used with php.

Background

Background example

$cmd = "$input -background NavajoWhite ". 
"-shear 15x15 -resize 213x" ; 
exec("convert $cmd background.jpg");

( Background sets the canvas colour and will be exposed when using other operators like rotate and shear. You can have a background of none which is transparent but the image must be saved as a gif or png. )

Bench

Measure performance.

Array ( [0] => Performance: 3i 0.158932ips

$cmd = "$input -resize 1000% -bench 3 "; 
exec("convert $cmd big.png 2>&1",  $output); 
print_r($output);

( Repeat the entire command for the given number of iterations; report the user-time and elapsed time.
Modify the benchmark with the -duration to run the benchmark for a fixed number of seconds and -concurrent to run the benchmark in parallel (requires the OpenMP feature).
3 iterations were completed at 0.158932 iterations per second. )

Bias

Add bias when convolving an image.

Bias example

$cmd = "$input -convolve \"-1,0,1,-1,0,1,-1,0,1\" -bias 20% ";  
exec("convert $cmd bias.jpg"); 
 

Black threshold

Black threshold example

$cmd = "$input -black-threshold 30%";  
exec("convert $cmd black_threshold.jpg");

( Force to black all pixels below the threshold while leaving all pixels at or above the threshold unchanged. )

Blackpoint compensation

Blackpoint compensation for a colour profile.

More information to follow.

$cmd = "$input -intent relative -black-point-compensation".
" -profile CMYK_PROFILE ";
exec("convert $cmd black-point-compensation.jpg");

Blend

Blend an image into another by the given percent.

Blend example

$cmd = "-size 213x160 xc:blue miff:- ". 
"| composite $input +swap -blend 70 - "; 
exec("convert $cmd blend.jpg");
  

( This is creating the blue image to blend as well as blending the two images. *** should be able to define the size of the blue image from the size of the image *** )

Blue primary

Set the blue chromaticity primary point.

Blue primary example

$cmd = "$input -blue-primary 80,80";   
exec("convert $cmd blue-primary.jpg");
 

Blue shift

Simulate a scene at nighttime in the moonlight. Start with a factor of 1.5

Blue shift example

$cmd = "$input -blue-shift 1.5 "; 
exec("convert $cmd blue-shift.jpg");

Blur

Reduce image noise and reduce detail levels.

Blur example

Another Blur example

$cmd = "$input -blur 15"; 
exec("convert $cmd blur_simple.jpg");

$cmd = "$input -blur 0x3"; 
exec("convert $cmd blur.jpg");