The background transformation is useful when you want to set the background of a PNG image that has transparency or if you are using it with other transforms (like pad_resize crop mode, radius etc.) which introduce a transparency or a solid background in the output image.
The background transformation is represented by the keyword 'bg'. It currently accepts hex code values for the color that has to be used as the background. The hex code is represented in the format `RRGGBBAA` or `RRGGBB`. If you are using the 8-character representation for the background, then the last two characters (shown as 'AA') represent the opacity of the background color. The value 00 corresponds to complete transparency (opacity - 0.0) and the value 99 indicates opacity - 0.99 (nearly opaque). If you do not specify the opacity value, then the default opacity value in the 6-character hex code representation is 1 (completely opaque). Note that opacity in the background color doesn't work for specifying the background of a PNG image.
Let's take a look at some example URLs and output images
1. Specifying a background for a PNG image
2. Specifying a red background with opacity 0.3 (AA = 30), pad resize crop mode
The border transformation, as the name suggests, adds a border to the image. It accepts two parameters - the width of the border and the color of the border.
The transformation is represented using the keyword 'b'. The width is specified as a number which is equivalent to the border width in pixels. The color code is specified as a 6-character hex code RRGGBB.
1. Adding a 5 pixel yellow border to a 300px resized image
2. Adding a 20 pixel red border to a 300px resized image