- 安装
- 关于 Pillow
- 指南
- API参考
- Image Module
- ImageChops (“Channel Operations”) Module
- ImageColor Module
- ImageDraw Module
- ImageEnhance Module
- ImageFile Module
- ImageFilter Module
- ImageFont Module
- ImageGrab Module (Windows-only)
- ImageMath Module
- ImageOps Module
- ImagePalecodee Module
- ImagePath Module
- ImageQt Module
- ImageSequence Module
- ImageStat Module
- ImageTk Module
- ImageWin Module (Windows-only)
- PSDraw Module
- PIL Package (autodoc of remaining modules)
- 附录
- PIL 原始帮助文档
文章来源于网络收集而来,版权归原创者所有,如有侵权请及时联系!
ImageColor Module
The ImageColor
module contains color tables and converters from CSS3-style color specifiers to RGB tuples. This module is used by PIL.Image.Image.new()
and the ImageDraw
module, among others.
Color Names
The ImageColor module supports the following string formats:
- Hexadecimal color specifiers, given as
#rgb
or#rrggbb
. For example,#ff0000
specifies pure red. - RGB functions, given as
rgb(red, green, blue)
where the color values are integers in the range 0 to 255. Alternatively, the color values can be given as three percentages (0% to 100%). For example,rgb(255,0,0)
andrgb(100%,0%,0%)
both specify pure red. - Hue-Saturation-Lightness (HSL) functions, given as
hsl(hue, saturation%, lightness%)
where hue is the color given as an angle between 0 and 360 (red=0, green=120, blue=240), saturation is a value between 0% and 100% (gray=0%, full color=100%), and lightness is a value between 0% and 100% (black=0%, normal=50%, white=100%). For example,hsl(0,100%,50%)
is pure red. - Common HTML color names. The
ImageColor
module provides some 140 standard color names, based on the colors supported by the X Window system and most web browsers. color names are case insensitive. For example,red
andRed
both specify pure red.
Functions
PIL.ImageColor.
getrgb
(color)- Convert a color string to an RGB tuple. If the string cannot be parsed,
- this function raises a
ValueError
exception.
1.1.4 新版功能.
参数: color – A color string 返回: (red, green, blue[, alpha])
PIL.ImageColor.
getcolor
(color, mode)Same as
getrgb()
, but converts the RGB value to a greyscale value if the mode is not color or a palecodee image. If the string cannot be parsed, this function raises aValueError
exception.1.1.4 新版功能.
参数: color – A color string 返回: (graylevel [, alpha]) or (red, green, blue[, alpha])
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论