Python ImageColor Module



The ImageColor module contains colour tables and converters.
This module is used by Image.new and the ImageDraw module, among others.

Functions

function Description
getcolor(color, mode) This function takes a color name strings as its first argument and the string 'RGBA' as the second argumentand and it returns an RGBA tuple
getrgb(color) Convert a colour string to an RGB tuple. If the string cannot be parsed, this function raises a ValueError exception

Example
>>> from PIL import ImageColor
>>> ImageColor.getcolor('red','RGBA')
(255, 0, 0, 255)
>>> ImageColor.getcolor('RED','RGBA')
(255, 0, 0, 255)
>>> ImageColor.getcolor('Black','RGBA')
(0, 0, 0, 255)
>>> ImageColor.getcolor('chocolate','RGBA')
(210, 105, 30, 255)
>>> ImageColor.getcolor('CornflowerBlue','RGBA')
(100, 149, 237, 255)
Advertisements