Rubblewebs

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.

Round border

Round border example
 // Creating a canvas with a colour of peachpuff, drawing a cicle filled lightblue
// with a 10pixel black border, turning the light blue center transparent.
$cmd = " -size 400x300 xc:PeachPuff -fill LightBlue -stroke black -strokewidth 10 ".
" -draw \"circle 190,150 190,10\" -transparent LightBlue ";
exec("convert $cmd mask.png");

// Overlaying the mask made above over the photo
exec("convert $input20 mask.png -composite temp.png");

// Converting the peachpuff canvas to transparent.
exec("convert temp.png -transparent PeachPuff temp.gif");

// crop execss picture
exec("convert temp.gif -crop 296x296+44+4 +repage round_border.gif");

// Delete the tempory images
unlink( 'mask.png' );
unlink( 'temp.gif' );
unlink( 'temp.png' );

Changing a square picture to a round one with a border. The picture is still square but the backgound is transparent.


Back