Help_Python_Pls Help_Python_Pls - 6 months ago 8
Python Question

Python: Getting a syntax error. Possibly due to incorrect installation of the PIL library

width, height = img.size
total = 0
for row in range(width):
for col in range(height):
# This will save the RGBA values of the pixel
red, green, blue, alpha = img.getpixel( (row, col) )
new_red = red + new_red
new_green = green + new_green
new_blue = blue + new_blue
total = 1 + total

average_red = new_red/total
average_green = new_green/total
average_blue = new_blue/total
img.putpixel((row, col,), (average_red, average_green, average_blue, 255)

I'm getting a syntax error when using that. I am guessing that it could be due to the incorrect installation of the PIL module.

Anybody aware if this is the case?

If so, can someone guide me to an installation guide on how to install it in Mac OSX?


You're missing a ) at the end of

img.putpixel((row, col), (average_red, average_green, average_blue, 255)

It should be

img.putpixel((row, col), (average_red, average_green, average_blue, 255))