[Image-SIG] float rgba list -> Image

Ingo Randolf ingo at quitch.net
Wed Aug 31 16:21:46 CEST 2011

Hi all.

I have a list with float-values describing an image like this:
[R, G, B, A, R, G, B, A, R, G, B, A, R, G, B, A, R, G, B, A, ... etc.]

the RGBA-values are from 0. - 1.

is there a clever way to make a PIL-Image out of something like this?

i played around with putdata... and came along with this, very, very slow solution:

px = list-of-rgba-values-as-floats
img = the-image

#make int-tuples
newdata = [(int(px[(x*4)]*255), int(px[(x*4)+1]*255), int(px[(x*4)+2]*255), int(px[(x*4)+3]*255)) for x in range( img.size[0] * img.size[1] )]

well i never saw a result, because it took too long for my short patience... ;)

i also tried to set the values pixel-wise... this is also very, very slow...

how to do that in a more clever way?

thanks for any hints

More information about the Image-SIG mailing list