ariel
ariel

Reputation: 21

fade out in Image module Python

I want to take a BMP or JPG and duplicate it so the new image will darker (or brighrt) what function can I use? Ariel

Upvotes: 2

Views: 2298

Answers (2)

whatnick
whatnick

Reputation: 5480

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.

Upvotes: 1

rob
rob

Reputation: 37664

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.

Upvotes: 7

Related Questions