Create a 'disabled' image effect (similar to how Windows shows disabled images)

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Create a 'disabled' image effect (similar to how Windows shows disabled images)

python@bdurham.com
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  -  [hidden email]
http://mail.python.org/mailman/listinfo/image-sig
Reply | Threaded
Open this post in threaded view
|

Re: Create a 'disabled' image effect (similar to how Windows shows disabled images)

Edward Cannon
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,  <[hidden email]> 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  -  [hidden email]
> http://mail.python.org/mailman/listinfo/image-sig
>
>
_______________________________________________
Image-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/image-sig
Reply | Threaded
Open this post in threaded view
|

Re: Create a 'disabled' image effect (similar to how Windows shows disabled images)

kevin-28
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,  <[hidden email]> 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  -  [hidden email]
>> http://mail.python.org/mailman/listinfo/image-sig
>>
>>
> _______________________________________________
> Image-SIG maillist  -  [hidden email]
> http://mail.python.org/mailman/listinfo/image-sig

_______________________________________________
Image-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/image-sig