i want put hsl data rgba image. code:
import image myimage = image.new("rgba", (100, 100), (0,0,0,255)) h = 180 s = 100 l = 50 hsl_string = "hsl(" + str(h) + "," + str(s) + "%," + str(l) + "%)" print hsl_string myimage.putpixel((2, 2), hsl_string)
this gives me following error putpixel function: typeerror: new style getargs format argument not tuple. however, hsl_string hsl(180,100%,50%), similar stated in pil documentation.
replacing hsl_string e.g. (0,0,0,0) works well, replacing (0,0,0) (an rgb value without opacity despite image rgba).
what error mean? , how can add value opacity (the alpha channel) hsl value @ all?
try using getrgb
function imagecolor
module:
myimage.putpixel((2, 2), imagecolor.getrgb(hsl_string))
you can add alpha value this:
alpha = 255 myimage.putpixel((2, 2), imagecolor.getrgb(hsl_string) + (alpha, ))
Comments
Post a Comment