Every enhancer works the same way. Make one from an image, then call enhance with a factor.
from PIL import Image, ImageEnhance
im = Image.open("photo.jpg")
brighter = ImageEnhance.Brightness(im).enhance(1.3)
1.0 always returns the original. Below 1.0 moves towards the degenerate version of that property, above 1.0 moves away from it.
| Enhancer | 0.0 gives you | Above 1.0 |
|---|---|---|
Brightness | A black image | Brighter |
Contrast | A flat grey image at the average brightness | More contrast |
Color | Greyscale | More saturated |
Sharpness | Blurred | Sharpened |
That is the whole idea: interpolate between a degenerate image and the original, and keep going past it. Values are clipped at the ends of the range, so you cannot push a channel below 0 or above 255.
im = ImageEnhance.Color(im).enhance(1.15)
im = ImageEnhance.Contrast(im).enhance(1.1)
im = ImageEnhance.Sharpness(im).enhance(1.4)
Small numbers do more than people expect. Anything past about 1.5 on colour starts looking like a phone filter. Apply enhancements before you resize down, not after, because resizing averages away some of what you just did.
ImageEnhance.Sharpness is a simple blend towards or away from a blurred copy. For real sharpening, particularly after resizing, ImageFilter.UnsharpMask gives you radius and threshold as well as strength, and does a better job. See the filter module.
The playground has sliders for brightness and contrast and writes the matching code.