Expands an image or matrix canvas by adding constant-value padding around the original image.

render_padding(
  image,
  pad = 10,
  color = "black",
  alpha = NULL,
  filename = NULL,
  preview = FALSE
)

Arguments

image

3-layer RGB/4-layer RGBA array, rayimg class, matrix, or filename of an image.

pad

Default 10. Padding in pixels. Use a scalar for equal padding on all sides, or c(top, right, bottom, left).

color

Default "black". Padding color. Can be a scalar, RGB/RGBA numeric vector, or R color string.

alpha

Default NULL. Padding alpha for images with an alpha channel. If NULL, uses the alpha channel supplied in color when present, otherwise defaults to 0 when color is omitted and 1 when color is supplied. Ignored for RGB and matrix inputs.

filename

Default NULL. File to save the image to. If NULL and preview = FALSE, returns the padded image.

preview

Default FALSE. If TRUE, display the padded image.

Value

A padded rayimg image or matrix.

Examples

render_padding(dragon, pad = 20) |>
 plot_image()