jdriscoll/django-imagekit — Issue #64: Adjust Is Not Transparency-Compatible
Author: matthewwithanm
Created: 2011-11-12 02:59:04+00:00
State: open

With the addition of the [AutoConvert processor][0], ImageKit can now handle different transparency formats a lot more intelligently than it used to; the `Adjust` processor needs to be updated to match.

The first problem is that the processor [converts to 'RGB'][1]. This is a pretty quick fix as we can just change this to RGBA. Unfortunately, that's not quite enough: PIL's [color and contrast filters][2] don't behave as expected with transparencies. That because both of their implementations involve converting the image to L mode:

class Color(_Enhance):
"Adjust image colour balance"
def __init__(self, image):
self.image = image
self.degenerate = image.convert("L").convert(image.mode)

class Contrast(_Enhance):
"Adjust image contrast"
def __init__(self, image):
self.image = image
mean = int(ImageStat.Stat(image.convert("L")).mean[0] + 0.5)
self.degenerate = Image.new("L", image.size, mean).convert(image.mode)

So basically, we have to write new versions of these two that don't.

Any takers? (:

[0]: https://github.com/jdriscoll/django-imagekit/blob/develop/imagekit/processors/__init__.py#L179
[1]: https://github.com/jdriscoll/django-imagekit/blob/develop/imagekit/processors/__init__.py#L63
[2]: http://www.pythonware.com/library/pil/handbook/imageenhance.htm