I’m getting an error in my code, but I can’t determine why. (getpixel() accepts 2 positional arguments, but gives 3)… here is a solution to the problem.
I’m getting an error in my code, but I can’t determine why. (getpixel() accepts 2 positional arguments, but gives 3)
I’m programming for a project so I can easily determine how many pixels I want to fill for images for my website. However, I got this error: getpixel() takes 2 positional arguments but 3 were given.
My code is as follows:
from PIL import Image
import PIL. ImageOps
background = Image.open("background.png")
target = input("Please enter the name of your image (including file type)")
targetImage = Image.open(target)
area = targetImage.size
targetColouredCoords = []
newArea = (area[0] + 1, area[1] + 1)
borderedTarget = PIL. ImageOps.expand(targetImage, border=10, fill="black")
targetValues = list(borderedTarget.getdata())
def analyser():
pixelOne = 1
pixelTwo = 1
completedSearch = 0
currentPixel = borderedTarget.getpixel(pixelOne, pixelTwo)
def colourChecker():
if currentPixel != (0, 0, 0):
targetColouredCoords.append((pixelOne, pixelTwo))
while completedSearch != len(targetValues):
while pixelOne != newArea[0]:
while pixelTwo != newArea[1]:
colourChecker()
pixelTwo += 1
completedSearch += 1
pixelTwo = 1
pixelOne += 1
analyser()
The only line I provide 3 arguments in the whole code is 18, but I don’t understand how this line of code is incorrect or how the code is highlighted as a problem (line 26) is wrong. I can’t continue coding until the error is removed, so thank you very much for your help.