Disappear in Python Image Module

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

+2


source to share


2 answers


You can use the ImageEnhance PIL module :

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)

      



Check out the PIL and ImageEnhance documentation for more details.
Note. I find the ImageEnhancer documentation is a bit too complicated and you might need some experimentation on the interactive prompt to get the right solution.

+7


source


If you want to do it in a complex way, i.e. code, change the pixel intensity by pixel. Here's how to do it: 1) Convert from RGB to HSI 2) Increase or decrease the intensity component 3) Convert from HSI to RGB



True attenuation, i.e. no alpha channel in JPG or BMP [RGBA image in PIL]. You get black to white using the intensity method. If you want to use the alpha version of png or tiff instead.

+1


source







All Articles