Basic problems of python PIL image processing

written according to many examples on the Internet, python3 version environment

< H2 > Test Code 1 < / H2 >
from PIL import Image
img = Image.open("qqqqq.png")
print (img.size)               -sharp(10,24)
print(img.getpixel((10,24)))   -sharp:
                               -sharp IndexError: image index out of range

the picture is 10 to 24 in size, so why is it out of range? Do you want to subtract the coordinates by 1? The point in the lower right corner should be (9 ~ 23)?

< H2 > Test Code 2 < / H2 >
from PIL import Image
img = Image.open("qqqqq.png")
print(img.getpixel((4,4)))     -sharp:3

what does this 3 mean? Shouldn"t it be a result similar to (255255255)?

< H2 > Test Code 3 < / H2 >
img = Image.open("qqqqq.png")
img.putpixel((4,4),(255,255,0))   -sharp:
                                  -sharpTypeError: function takes exactly 1 argument (3 given)  
img.save("qqqqq-2.png","png")

change the color of a pixel and look at the wrong number of parameters given by the error prompt.

< H1 > awkward, ask a question and think of the reason. < / H1 > < H1 > the reason is the png diagram pattern. Pay attention to the rookie who comes later < / H1 >.
Sep.01,2021

the reason is the png diagram pattern. The rookie who comes later should pay attention to

.
Menu