Python Imaging Library: ImageColor Module(图像颜色模块)

Python Imaging Library: ImageColor Module(图像颜色模块)

图像颜色模块(ImageColor Module)支持的字符串格式如下:

  • 十六进制(Hexadecimal )颜色说明符,如“#rgb”或“#rrggbb”。例如,“#ff0000” 表示纯红色。

  • RGB函数,如“rgb(red, green, blue)” ,其中颜色值取值范围为【0-255】的整数。作为另外一种选择,也可以使用百分比(0%-100%)。例如“rgb(255,0,0)”“rgb(100%,0%,0%)” 都表示纯红色。

  • Hue-Saturation-Lightness (HSL)函数,如“hsl(hue, saturation%, lightness%)” ,色度(Hue)取值范围为【0-360】(red=0, green=120, blue=240),饱和度(Saturation)取值范围为【0%-100%】 (gray=0%, full color=100%),亮度(lightness取值范围为【0%-100% (black=0%, normal=50%, white=100%)。例如“hsl(0,100%,50%)”表示纯红色。

  • 通用HTML颜色名称。图像颜色模块(ImageColor Module)支持140种标准颜色名称,包含基于X窗口系统和大多数web浏览器支持的颜色。颜色名称不区分大小写。例如“red” and “Red” 表示纯红色。

函数

getrgb(color) ⇒ (red, green, blue)

(New in 1.1.4) Convert a colour string to an RGB tuple. If the string cannot be parsed, this function raises a ValueError exception.

getcolor(color, mode) ⇒ (red, green, blue) or integer

(New in 1.1.4) Same as getrgb, but converts the RGB value to a greyscale value if the mode is not color or a palette image. If the string cannot be parsed, this function raises a ValueError exception.


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值