Saturday, October 25, 2025
HomeLanguagesWand – Create empty image with background

Wand – Create empty image with background

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:
 
# other image manipulation code


Now Let’s see code to create backgrounds.
Example 1:
 

Python3




# import Image from wand.image module
from wand.image import Image
 
# create image using Image() function
with Image(width = 400, height = 300) as img:
 
    # Save image with a valid filename
    img.save(filename ='transparent.png')


Output : 
 

  
Example 2: Create a background with a solid green color 
 

Python3




# import Color from wand.color module
from wand.color import Color
# import Image from wand.image module
from wand.image import Image
 
clr = Color('green')
with Image(width = 400, height = 300, background = clr) as img:
    img.save(filename ='green.png')


Output : 
 

 

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS