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.

Pattern

Using one of ImageMagicks built in patterns for the background.

Pattern example
 
// Resize the image and add a 1 pixel border to it
$cmd = " sunflower.jpg -resize 250x250 -bordercolor coral4 -border 1x1 ";
exec("convert $cmd temp.jpg"); 

// Place the tempory image into the center of a 300x300px background
$cmd = " -size 300x250 pattern:BRICKS -bordercolor coral4 ".
" -border 1x1 temp.jpg -gravity center -composite ";
exec("convert $cmd pattern.jpg"); 

// Delete the tempory image
unlink("temp.jpg");


Back