Oct-11-2018, 09:07 AM
Hi,
I am trying to use pillow for an online python photo manipulation course, I am only starting at the basics one of my tasks is to write a program converts an image to a sepia filter. It says that I have to convert it to grayscale and then add some adjustments. I have written some code, I have tried it on 2 images it gave me, however on only one certain image it gave me an error. My code is:
Thanks for your time.
I am trying to use pillow for an online python photo manipulation course, I am only starting at the basics one of my tasks is to write a program converts an image to a sepia filter. It says that I have to convert it to grayscale and then add some adjustments. I have written some code, I have tried it on 2 images it gave me, however on only one certain image it gave me an error. My code is:
from PIL import Image file = input("File name: ") img = Image.open(file) red,green,blue = img.split() for y in range(img.height): for x in range(img.width): r = red.getpixel((x,y)) g = green.getpixel((x,y)) b = blue.getpixel((x,y)) total = (r+g+b) avg = int((total/3)) red.putpixel((x,y),avg+30) green.putpixel((x,y),avg+10) blue.putpixel((x,y),avg-10) new_image = Image.merge('RGB', (red, green, blue)) new_image.save("output.png")When I try to do that certain image it says:
Error:Traceback (most recent call last):
File "program.py", line 5, in <module>
red,green,blue = img.split()
ValueError: too many values to unpack (expected 3)
Does anyone have any idea on how to fix this because it only does this error on this one certain picture.Thanks for your time.