Question

I am wondering whats the best way to programmatically make rounded corners for images. This can be either using PHP or javascript. An algorithm will also do for the same and I can code it with Image::Magick or GD.

Thank you for your time.

Was it helpful?

Solution

OTHER TIPS

Use border-radius.

It is supported in IE9+, Firefox 4+, Chrome, Safari 5+, and Opera.

For the best possible browser support, you should prefix with -webkit- and -moz-:

.round {
  /* Safari 3-4, iOS 1-3.2, Android 1.6- */
  -webkit-border-radius: 12px; 

  /* Firefox 1-3.6 */
  -moz-border-radius: 12px; 

  /* Opera 10.5, IE 9, Safari 5, Chrome, Firefox 4, iOS 4, Android 2.1+ */
  border-radius: 12px; 
}

If you need a JavaScript solution for older browsers check out jQuery Corner.

Well, it depends what exactly you need. Do you want the corners to be transparent, or filled in some color? Which image format?

Here is some help for making rounded corners: http://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=8401

Check it out, and if it does not help, update your question with the specific problem. Then we can probably help :-):

You can use the above mention tags with CSS, and for IE, use DDRoundies with some jquery code to make it work in IE. It is what I had to do to get it working. Good example of this is http://swiftmailer.org/ site. they make use of what I mentioned.

use JavaScript to programatically get round corners

OR

you can use mozilla and safaris browser extensions to get round corners using CSS but it will work only in Mozilla and Safari

-moz-border-radius: 5px;
-webkit-border-radius: 5px;

Here are links for two PHP based solutions:

  1. Apply rounded corners to images is a PHP script that embeds rounded corner on the image itself
  2. PHP rounded corner generator script generates four corners that you can place over your image using CSS positioning -- or you can use them in your CSS/HTML layouts that require boxes with round corner.

Another one is the Thumbnailer class.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top