- PIL Home
- Python Image Library Intro
- Python Image Library Setup
- Python Image Library Basics
- Python Image Library Hierarchy
- Python Image Library Modules
- Python ImageColor Module
- Python ImageDraw Module
- Python ImageStat Module
- Python ImageTK Module
- Python ImageFile Module
- Python ImageFilter Module
- Python ImageGrab Module
- Python ImageMath Module
- Python - Loading Image
- Python - Rotating Image
- Python - Blurring Image
- Python - Converting Image
- Python - Cropping Image
- Python - Image Thumbnails
- Python - Text on Images
- Python - Multiple Image Copies
- Python - Saving Image As PDF
- Python - Saving Screenshot
- Python - Resizing Image
- Python - Adding Watermark
- Python Image Library Resources
- Python - Quick Guide
- Python - Useful Resources
- Python - Discussion
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 |
>>> 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