[Image-SIG] Creating a grayscale ramp

Cochran, Travis Travis.Cochran at analog.com
Mon Jan 22 14:40:44 CET 2007


I'm trying to use the PIL to create a grayscale ramp, dark to light. I
am able to generate an image but it is solid black. Am I using
frombuffer wrong? Here is my code.

from PIL import Image

#Creates the list of codes from 0 to 255
data = range(256) 
#Creates an image out of those codes
im = Image.frombuffer("L", (256, 1), str(data), "raw", "L", 0, 1)
#Resizes the image to make it easy to view
im = im.resize((256, 768)).show()


More information about the Image-SIG mailing list