Dec-07-2018, 01:31 AM
(Dec-06-2018, 03:21 PM)j.crater Wrote: Hello
pixel = img.getpixel((x,y)) value = img.getpixel((x,y))What is the purpose of these seemingly same operations, why doubled?
You get all x and y pixels in the inner for loop, but you set the pixel value (+50) outside of that loop. So I would guess it only changes the last pixel it iterates over, when the for loops exit. Instead you should do that inside the loop.
Hi, thank you for your help~
When removing the line for inner for loop I get error messages, same goes for it I added the 50 and then remove it for the outside of the loop. Vice versa gives me errors as well. Leaving them both gives me no error besides not brightening the image.
I decided to just leave that code alone since it isn't doing anything. I tried something a little different with the code here;
from PIL import Image file = input("File name: ") img = Image.open(file) width, height = img.size value = img.getpixel(img.size) img.putpixel(value + 50) img.save("output.png")I get this error however;
"Traceback (most recent call last):
File "program.py", line 5, in <module>
value = img.getpixel(img.size)
File "/opt/python-3.6/lib/python3.6/site-packages/PIL/Image.py", line 1227, in getpixel
return self.im.getpixel(xy)
IndexError: image index out of range"
I've never seen it before so I'm not sure what it means? I feel like I'm just making things worse at this point.