开发者

fade out in Image module Python

I want to take a BMP or JPG and duplicate it so the ne开发者_开发知识库w image will darker (or brighrt) what function can I use? Ariel


You can use ImageEnhance module of PIL:

import Image
import ImageEnhance

image = Image.open(r'c:\temp\20090809210.jpg')
enhancer = ImageEnhance.Brightness(image)
brighter_image = enhancer.enhance(2)
darker_image = enhancer.enhance(0.5)

Look at PIL and ImageEnhance documentation for more details.
Note: I think ImageEnhancer documentation is a bit too terse, and you may need some experimenting within the interactive prompt to get it right.


If you want to do it the hard way i.e. code up a pixel by pixel intensity change. Here is how: 1) Convert from RGB to HSI 2) Increase or decrease the Intensity component 3) Conver back from HSI to RGB

True fade out i.e. alpha channel is not present in the JPG or BMP formats [ RGBA format image in PIL] . You get black to white using the the intensity technique. If you want to use alpha use png or tiff instead.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜