I'm struggling hard and am still new to coding, I have an assignment due and was looking for advice on my code as I have frequent improper syntax. I can already see a few mistakes such as pix and being unsure of where to specify specific x,y coordinates, but here's what I have so far (assignment requirements are near the bottom):
from PIL import Image
img2 = Image.open("edinburgh-castle.jpg")
width,height = img2.size
def draw_lines(img):
for x in range (width):
for y in range(height):
pix = img2.getpixel((x,y))
img2.getpixel((106,240))
green_component = pix[1]
newpix = (green_component,green_component,green_component,green_component)
img2.putpixel((106,240),newpix)
img.save("edinburgh-castle.jpg")
img2.show("edinburgh-castle.jpg")
for x in range(width):
for y in range(height):
pix = img2.getpixel((x,y))
img2.getpixel((320,80))
blue_component = pix[2]
newpix = (blue_component,blue_component,blue_component,blue_component)
img2.putpixel((320,80),newpix)
img.save("edinburgh-castle.jpg")
img2.show("edinburgh-castle.jpg")
return img
-
Draw your green and blue lines on the image*Write code below to draw a green vertical line from top to bottom, 1/3 of the way across the edinburgh-castle.gif; also draw a horizontal blue line 1/3 of the way down the same image. Return the image
I'm not receiving specific error, but I'm not getting an output either, even when commenting out return. The image dimensions are 320x240