Skip to content

Latest commit

 

History

History
30 lines (20 loc) · 743 Bytes

how-to-set-background-color.md

File metadata and controls

30 lines (20 loc) · 743 Bytes

How to set background color

Background is set as a color argument of Image.new method:

from PIL import Image, ImageFilter

im = Image.new(mode='RGB', size=(300,300), color=(150,200,50))

im.show()
  • PIL - import lib:Pillow package modules
  • Image.new - create new PIL image object
  • mode='RGB' - create new image in RGB color mode
  • (300,300) - new image width and height
  • (150,200,50) - background color as an RGB tuple
  • .show() - displays resulting image

group: create

Example:

from PIL import Image, ImageFilter

im = Image.new(mode='RGB', size=(300,300), color=(150,200,50))

im.show()