Monthly Archives: September 2012

ImageMagick: Rounded-corner PHP function

I’ve converted my rounded-corner bash script into a PHP function that’ll use the Image Magick command line tools to do the same. With some added functionality to handle automatically creating thumbnails and applying a background color to the source image itself. This also allows for the insertion of basic pre-processing and post-processing arguments to IM.

For more information and output examples see. the bash version.

To see an example of thumbnails generated with some pre-processing done:

First Preprocessor Test

This is a sample done with thumbnail pre-processing. That is processing done before the rounded corners are made.

With this sample, I switched colorspace to HSL and then set the hue and saturation to a constant before applying the glass-bubble rounded corners.

Known bug: sometimes the glass-bubble method will add a single pixel to the width, which is transparent. I believe passing -trim in the postprocessing option may trim that off for you, though I have not thoroughly tested it.

Also: I have no idea if this will work on a Windows server.

Continue reading