Back to the snippets index

Apply rounded corners to an image

( IM Forum 19/6/2008 )

Add rounded corners to an image.

IM code:

<?php  
// Get the dimensions of the original image
$size getimagesize('input.jpg');
// Create a rounded corner mask to overlapp the image
$cmd " -size {$size[0]}x{$size[1]} xc:none -fill white ".
" -draw \"roundRectangle 0,0 {$size[0]},{$size[1]} 15,15\" ".
" input.jpg -compose SrcIn -composite "
exec("convert $cmd output.png"); 
?>

Image to go with Apply rounded corners to an image example code