I Try to using PIL.Image.putpixel(xy,color) ,But always fail. It's work for put singel channel graycolor PIL.Image.putpixel((x,y),255) But I want to put RGB color to this picture.
trackback -> TypeError: function takes exactly 1 argument (3 given)
Not: 123.jpg is grayscale picture.
Code Below:
from PIL import Image
img = Image.open("123.jpg")
img.convert('RGB')
for x in range(img.size[0]):
for y in range(img.size[1]):
img.putpixel((x, y), (255, 255, 255))
img.save("temp.jpg")
img.show()
It should be
img.putpixel(...)
(Change im to img)
After correcting that, it should work.
The Image.convert()
method returns an altered copy without changing the original, but you actually want to use the altered version, so replace:
from PIL import Image
img = Image.open("123.jpg")
img.convert('RGB')
with
from PIL import Image
img = Image.open("123.jpg").convert('RGB')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.