Add a border to images
Add a border to images
Presentation
Photography
Beginner

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: Original

In our first example, we'll simply add a solid black 2 pixel border to the image: Bordered

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: Trimmed

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: Colored circle

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: Overlay border

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%: Semi-transparent border