Layer Background attribute¶
- class Background¶
When combining these attributes, the
image
is tinted with thecolor
.Hint
If no alpha transparency is included with the specified
color
, then thecolor
will block out theimage
.- image : str | None¶
The path to an image used as the card’s background. This path can be absolute or relative to one of the paths specified in
social_cards.image_paths
.Missing file extensions
If the image file’s name does not include a file extension (eg
.png
), then it is assumed to ba a SVG image (.svg
is appended to the filename).By default, this image will be resized to fit within the layer’s
size
. Seepreserve_aspect
for more details on resizing images.
- color : Color | Linear_Gradient | Radial_Gradient | Conical_Gradient | None¶
The color used as the background fill color. This color will overlay the entire
background.image
(if specified). So be sure to add transparency (an alpha color value) when using both a background image and color.Seealso
Please review Choosing a color section for more detail.
- preserve_aspect : bool | Literal['width', 'height']¶
If an image is used that doesn’t match the layer’s
size
, then the image will be resized accordingly. This option can be used to control which horizontalwidth
or verticalheight
or both (true
) constraints are respected. Set this option tofalse
to disable resizing the image. By default, this option is set totrue
.If the image has to be resized then it is centered on the layer for which it is used.