Imagemagick operators page: 5

Contrast

Enhance or reduce the image contrast.

Contrast example
<?php 
$cmd 
"$input -contrast"
exec("convert $cmd contrast.jpg");
  
?>

Contrast stretch

Increase the contrast in an image by stretching the range of intensity values.

Contrast stretch example
<?php 
$cmd 
"$input -contrast-stretch \"2%\" "
exec("convert $cmd contrast-stretch.jpg");
   
?>

Convolve

Convolve an image with a user supplied convolution kernel.

Convolve example
<?php 
$cmd 
"$input -convolve \"-1,0,1,-1,0,1,-1,0,1\"  "
exec("convert $cmd convolve.jpg");
    
?>

Crop

Cut out one or more rectangular regions of the image.

Crop example
<?php 
$cmd 
"$input -crop 133x140+80+25 +repage"
exec("convert $cmd crop.jpg");
   
?>

Cycle

Displace image colormap by amount.

Cycle example
<?php 
$cmd 
"$input -cycle 20"
exec("convert $cmd cycle.jpg");
  
?>

Debug

Enable debug printout.

Array([0] =>2009-06-06T19:52:00+01:00 0:01 0.000u 6.5.1 Configure convert[3624]: utility.c/ExpandFilenames/826/Configure
[1] =>Command line: convert {-debug} {all}{outp

<?php 
$array 
= array(); 
echo 
"<pre>"
exec("convert -debug all output.png output.jpg 2>&1"$array);  
echo 
"<br>".print_r($array)."<br>";  
echo 
"</pre>";
  
?>

( Only first two lines of output shown here. )

Decipher

Decipher and restore pixels that were previously transformed by -encipher.

Decipher example
<?php 
$cmd 
"encipher.png -decipher images/passkey.txt "
exec("convert $cmd decipher.png");
   
?>

Deconstruct

Find areas that has changed between images

More information to follow.


( Given a sequence of images all the same size, such as produced by -coalesce, replace the second and later images, with a smaller image of just the area that changed relative to the previous image.

The resulting sequence of images can be used to optimize an animation sequence, though will not work correctly for GIF animations when parts of the animation can go from opaque to transparent. )

Define

add specific global settings generally used to control coders and image processing operations

Define example
<?php 
$cmd 
"$input jpeg:size=200x200 ".
" -thumbnail 200x200 ";  
exec("convert $cmd define.jpg");
   
?>

( Can be used to speed up jpg conversions amongst other things )

Delay

Display the next image after pausing.

Delay example
<?php 
$cmd 
" -dispose previous -delay 50"
" -size 213x160 xc:none"
" -page +0+0 $input4 -page +8+18 $input4"
" -page +18+33 $input4 -page +28+48 $input4"
" -page +38+63 $input4 -page +48+82 $input4"
" -page +58+93 $input4 -page +68+78 $input4"
" -page +78+63 $input4 -page +88+48 $input4"
" -page +98+33 $input4 -page +108+18 $input4"
" -page +123+0 $input4 -loop 0"
exec("convert $cmd delay.gif"); 
 
?>

Delete

Delete the image, specified by its index, from the image sequence.

More information to follow.

<?php 
$cmd 
$input ( -clone 0 -thumbnail x480 -write 480_wide.jpg +delete )"
" -thumbnail 64x64! null: ";
 
exec("convert $cmd delete.jpg "); ?>

( Do not forget to change () to \(\) on a Linux system.
+delete to delete the last image in the current image sequence. )

Density

Set the horizontal and vertical resolution of an image for rendering to devices.

Density example
<?php 
$cmd 
"$input -density 200x200"
exec("convert $cmd density.jpg");
    
?>

Depth

Depth of the image.

Depth example
<?php 
$cmd 
"$input -depth 8";  
exec("convert $cmd depth.jpg");
  
?>

Descend

Obtain image by descending window hierarchy.

More information to follow.


( Not used with php )