[Image-SIG] Create a 'disabled' image effect (similar to how Windows shows disabled images)
Kevin Cazabon
kevin at cazabon.com
Wed Dec 1 21:26:25 CET 2010
I do this in some of my work too -
Making it black and white is one thing, but normally I'd suggest you also map the levels to a much narrower range (make black mid-gray, and white light-gray). I simple "point" can do that:
# make the image appear "deleted"
map = []
for q in range(3):
for i in range(256):
map.append(params.get("deletedMap")[0] + int(((params.get("deletedMap")[1] - params.get("deletedMap")[0]) * (i/256.0)) + 0.5))
image = image.point(map)
In my case I leave it as a color image, and the params.get simply pulls from a parameter class where I store my preferences for the darkest and lightest I want to map to. You can always replace that line with something simple like:
map.append(int(100 + (i * 0.25) + 0.5))
which will map it down to levels 100 to 164
Kevin.
On Dec 1, 2010, at 1:45 PM, Edward Cannon wrote:
> try using the Image.convert("L") method on you image. That will make
> it greyscale
> Edward Cannon
>
> On Wed, Dec 1, 2010 at 6:38 AM, <python at bdurham.com> wrote:
>> Any suggestions on a PIL receipe that will allow me to take a color image
>> and create a grayscale version of this image that gives the image a disabled
>> appearance similar to the effect that Windows applies to show disabled
>> icons?
>>
>> My use case is to dynamically create disabled versions of my application's
>> graphics when a specific feature is disabled or unavailable.
>>
>> Thank you,
>> Malcolm
>> _______________________________________________
>> Image-SIG maillist - Image-SIG at python.org
>> http://mail.python.org/mailman/listinfo/image-sig
>>
>>
> _______________________________________________
> Image-SIG maillist - Image-SIG at python.org
> http://mail.python.org/mailman/listinfo/image-sig
More information about the Image-SIG
mailing list