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.
Specify the offset for tile images, relative to the background image it is tiled on.
exec("convert $input1 -thumbnail 50x50 temp.png"); // Tile the image $cmd = " -size 213x160 -tile-offset +10+10 tile:temp.png "; exec("convert $cmd tile_offset.jpg");
( This is the offset from the datum position NOT the offset between the tiles. The default position is the top left corner. )
Tint the image with the fill color.
$cmd = "$input -fill Blue -tint 30"; exec("convert $cmd tint.jpg");
Transform the image.
This operator has been now been superseded by the -distort 'AffineProjection' method.Make this color transparent within the image.
$cmd = "$input -fuzz 10% -transparent #7b1216 "; exec("convert $cmd transparent.png");
( Save as a png to retain the transparency. -fuzz can be used to select a range of colours.
Also see Transparent inverted )
Set the transparent colour.
$cmd = "$input -transparent-color Black"; exec("convert $cmd transparent_color.jpg");
( This does not make a colour transparent, it only defines what colour the transparent colour is in the colour palette of the saved image. )
Make all colours except this color transparent within the image.
$cmd = "$input -fuzz 10% +transparent #7b1216 "; exec("convert $cmd plus_transparent.png");
( Save as a png to retain the transparency. -fuzz can be used to select a range of colours. )
Mirror the image along the top-left to bottom-right diagonal.
$cmd = "$input -transpose"; exec("convert $cmd transpose.jpg");
Mirror the image along the images bottom-left top-right diagonal.
$cmd = "$input -transverse"; exec("convert $cmd transverse.jpg");
Trim an image.
$cmd = "strokewidth.jpg -trim "; exec("convert $cmd trim.png");
( -fuzz can be added if the the border colour varies slightly. )
The image type.
$cmd = "$input -type Grayscale"; exec("convert $cmd type.jpg");
( Choose from: Bilevel, Grayscale, GrayscaleMatte, Palette, PaletteMatte, TrueColor, TrueColorMatte, ColorSeparation, or ColorSeparationMatte. )
Set the color of the annotation bounding box.
$cmd = "$input -fill Black -pointsize 40 -gravity center". " -undercolor NavajoWhite -annotate +0+0 \"Undercolor\""; exec("convert $cmd undercolor.jpg");
Discard all but one of any pixel color from the image.
$cmd = "$input4 -unique-colors -resize x20"; exec("convert $cmd unique_colors.jpg");
( Will create an image 1px high and VERY wide if your image contains a lot of colours. I have resized the height to 20px to see the colours. )