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.
Set a type of stretch style for fonts.
$cmd = "-size 213x160 -background NavajoWhite -fill black". " -gravity center -pointsize 30 -stretch UltraExpanded -font Arial caption:\"Stretch\" "; exec("convert $cmd stretch.jpg");
( Is not working! )
Strip the image of any profiles or comments.
$cmd = "$input -resize 100x100 -strip "; exec("convert $cmd strip.jpg");
( This will reduce the image filesize. )
Color to use when stroking a graphic primitive.
$cmd = "-size 213x160 xc:NavajoWhite -stroke black ". "-strokewidth 5 -fill none -draw \"circle 106,80 106,10 \" "; exec("convert $cmd stroke.jpg");
Strokewidth sets the line width.
$cmd = "-size 213x160 xc:NavajoWhite -stroke blue ". "-strokewidth 10 -fill none -draw \"circle 106,80 106,10 \" "; exec("convert $cmd strokewidth.jpg");
Set a font style for text - limited options
$cmd = "-size 213x160 xc:NavajoWhite -pointsize 30 -style italic ". " -draw \"gravity center fill black text 0,0 'Italic' \" "; exec("convert $cmd style.jpg");
Swap the positions of two images in the image sequence.
$cmd = "$input1 $input +swap -gravity center". " -composite "; exec("convert $cmd swap.jpg");
Swirl image pixels about the center.
$cmd = "$input -swirl 80"; exec("convert $cmd swirl.jpg");
Font for writing fixed-width text.
More information to follow.$cmd = "$input -fill white -pointsize 40". " -gravity center -text-font Arial ". " -annotate +0+0 \"Text font\""; exec("convert $cmd text-font.jpg");
Name of texture to tile onto the image background.
$cmd = " -size 313x260 pattern:BRICKS ". " $input -gravity center -composite ". "-resize 213 "; exec("convert $cmd texture.jpg");
( The bricks texture is one built into Imagemagick. )
Apply simultaneous black/white threshold to the image.
$cmd = "$input -channel red -threshold 25%"; exec("convert $cmd threshold.jpg");
Resize and thumbnail have the same effect but thumbnail strips the EXIF data etc.
$cmd = "$input -thumbnail 50% "; exec("convert $cmd thumbnail.jpg");
( Later versions do not strip the colour profile. )
Set the tile image used for filling a subsequent graphic primitive.
// Resize the boots image first to fit image exec("convert $input1 -thumbnail 50x50 temp.png"); // Tile the image $cmd = "-tile temp.png $input "; exec("composite $cmd tile.jpg");
( As this example is using composite rather than convert the images are in reverse order. )