Add a border to your images by setting the value of the
border parameter (
bo in URLs). The border's color, width and opacity can be customized dynamically, and borders can be applied either on main images or on overlaid images.
Here's an unmodified image we will use for our demonstration:
In our first example, we'll simply add a solid black 2 pixel border to the image:
We now use the
trim effect (as explained in the Trim photo background recipe) to trim the white spaces around the images.
In addition, we will round the image's corners (as explained in the Applying rounded corners to an image recipe) and then the border will be applied accordingly:
Here's the same image, cropped to a circle, centered on the automatically detected face (as explained in the Face detection-based image cropping recipe), and displayed with a red 2 pixel border:
You can also pass an RGB value for the border's color. In the following example we'll add an overlay image and set its border with an RGB value:
To set the opacity percentage of the border and make it semi-transparent, add an extra 2 hex digits to the color's RGB value. A value of FF will make the border solid, 00 will make it transparent.
For example, the following URL uses an opacity value of B2, which is approximately 70%: