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.
The units of image resolution.
$cmd = "$input -density 200x200". " -units PixelsPerInch"; exec("convert $cmd units.jpg");
Sharpen the image with an unsharp mask operator.
$cmd = "$input -unsharp 1.5"; exec("convert $cmd unsharp_simple.jpg");
Print detailed information about the image when this option preceds the -identify option or info:
Image: input.jpgsystem("convert $input -verbose -identify ");
( Will output an A4 size sheet of information about an image. )
Print ImageMagick version.
Version: ImageMagick 6.7.3-6 2011-11-10 Q16 http://www.imagemagick.orgecho ""; system("convert -version"); echo "";
( As we want the version displayed use system not exec. )
soften the edges of the image in vignette style.
$cmd = "$input -background none -vignette 0x6"; exec("convert $cmd vignette.png");
Specify contents of virtual pixels.
More information to follow.$cmd = "$input -matte -virtual-pixel NavajoWhite ". "-distort Perspective \"0,0 0,0 0,200 0,200 266,200 ". "266,180 266,0 266,20 \" "; exec("convert $cmd virtual_pixel.jpg");
Watermark an image using the given percentages of brightness and saturation.
$cmd = "-watermark 100% -gravity center $input1 $input"; exec("composite $cmd watermark.jpg");
Shear the columns of an image into a sine wave.
$cmd = "$input -background Blue -wave 50x100"; exec("convert $cmd wave.jpg");
Set a font weight for text.
$cmd = "$input -fill black -pointsize 30 -weight Bold". " -gravity center -annotate +2+2 \"Weight\""; exec("convert $cmd weight.jpg");
Chromaticity white point.
// Probably need to use with other operators $cmd = "$input -white-point 0.4,0.4"; exec("convert $cmd white-point.jpg");
( The "x" and "y" have nothing to do with the x,y position of a pixel on the image. Instead, they are coordinates of the white pixel in the chromaticity diagram (see the color diagram on the right of the page at http://en.wikipedia.org/wiki/Chromaticity) )
Force to white all pixels above the threshold while leaving all pixels at or below the threshold unchanged.
$cmd = "$input -white-threshold 50%"; exec("convert $cmd white_threshold.jpg");