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.
Obtain image by descending window hierarchy.
More information to follow.( Not used with php )
Straighten an image. A threshold of 40% works for most images.
$text = "ImageMagick is an external program that can be called from php."; // Create the skewed image for the example $cmd = " -size 200x150 -background white -pointsize 25 ". " -gravity NorthWest caption:\"$text\" "; exec("convert $cmd -rotate 2 text.png"); // Deskew the text exec("convert text.png -deskew 80% deskew.jpg");
Reduce the speckles within an image.
$cmd = "$input -despeckle "; exec("convert $cmd despeckle.jpg");
Render text right-to-left or left-to-right.
$text = "ImageMagick is an external program that can be called from php."; $cmd = " -size 200x150 -background NavajoWhite ". " -fill Black -gravity center ". " -direction right-to-left caption:\"$text\" "; exec("convert $cmd directionr.jpg"); $cmd = " -size 200x150 -background NavajoWhite ". " -fill Black -gravity center ". " -direction left-to-right caption:\"$text\" "; exec("convert $cmd directionl.jpg");
( There seems to be a problem with the right to left version but it might work properly with a font designed for this direction? )
Shift image pixels as defined by a displacement map.
More information to follow.$cmd = "$input -displace 17x7 "; exec("convert $cmd displace.jpg");
Define the GIF disposal image setting for images that are being created or read in.
$cmd = " -dispose none -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 dispose.gif");
Dissolve an image into another by the given percent.
$cmd = "-dissolve 10% $input1 $input "; exec("composite $cmd dissolve.jpg");
Launch a distributed pixel cache server.
Apply a Riemersma or Floyd-Steinberg error diffusion dither to images.
$cmd = "$input -dither Riemersma "; exec("convert $cmd minus_dither.jpg");
( Apply a Riemersma or Floyd-Steinberg error diffusion dither to images when general color reduction is applied via an option, or automagically when saving to specific formats. This enabled by default.
Turned on by default. )