Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a new color image with python Imaging?

I want to create a new image, with color in background.

This working:

img = Image.new('RGB', (width,height), "red")

But I want to customize the color. , when I change "red" by "(228,150,150) it doesn't working....

Have you an idea to do this?

like image 834
wxcvbn Avatar asked Aug 11 '16 15:08

wxcvbn


1 Answers

This is working for me. Note that the color tuple is not between quotes.

from PIL import Image

img = Image.new('RGB', (300, 200), (228, 150, 150))
img.show()

If it does not work for you, which version of Python and which version of PIL are you using?

like image 107
physicalattraction Avatar answered Oct 13 '22 01:10

physicalattraction