[Image-SIG] Fixes for PIL enhancers
Fredrik Lundh
fredrik@pythonware.com
Tue, 7 Jan 2003 22:23:39 +0100
Dinu Gherman wrote:
> I can't see it on the changes list from 1.1.3 to 1.1.4,
> so I'd be interested in your patches. (I just found that
> ImageEnhance.Brightness(img).enhance(f) would not intensify
> an image for f > 1, but only dim it down for 0 <= f < 1...
the bug is in Image.blend, not in the ImageEnhance module.
despite what the documentation says, the "blend" function only
works properly for alpha values between 0.0 and 1.0 (I have no
idea when this was changed). the fix is straightforward:
==== //modules/pil/PIL/Image.py
*** 1530,1539 ****
def blend(im1, im2, alpha):
"Interpolate between images."
- if alpha <= 0.0:
- return im1
- elif alpha >= 1.0:
- return im2
im1.load()
im2.load()
return im1._new(core.blend(im1.im, im2.im, alpha))
--- 1530,1535 ----
</F>