Wand – Create empty image with background
Last Updated :
21 Jul, 2021
In Python we can create solid backgrounds using Wand. We can use these backgrounds for further use in image. We can use these backgrounds in a backgroundless image to make it more attractive. This can be done by simply using Image() function and setting width, height and background parameter.
Syntax :
Python3
with Image(width = <i>image_width < / i>,
height = <i>image_height < / i>,
background = 'color' ) as img:
|
Now Let’s see code to create backgrounds.
Example 1:
Python3
from wand.image import Image
with Image(width = 400 , height = 300 ) as img:
img.save(filename = 'transparent.png' )
|
Output :
Example 2: Create a background with a solid green color
Python3
from wand.color import Color
from wand.image import Image
clr = Color( 'green' )
with Image(width = 400 , height = 300 , background = clr) as img:
img.save(filename = 'green.png' )
|
Output :
Share your thoughts in the comments
Please Login to comment...