How to fix if-elif-else syntax error?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sbtunx
    New Member
    • Feb 2011
    • 8

    How to fix if-elif-else syntax error?

    hi
    the problem is a syntax error that highlights pink the "elif" in the program just that. this code is to water mark picture "test.jpg" with the water mark of "model.jpg" with a mark on a white background the cod is:
    Code:
    import Image,math
    model = Image.open("model.jpg")
    test = Image.open("test.jpg")
    x=test.size[0]
    y=test.size[1]
    im  = Image.new("RGB",(x,y))
    
    for i in range(300):
     for j in range(300):
    
      rpixel,gpixel,bpixel=test.getpixel((i,j))
      rmodel,gmodel,bmodel=model.getpixel((i,j))
      
      if 255==rmodel and 255==gmodel and 255==bmodel:
       im.putpixel((i,j),(rpixel,gpixel,bpixel)
      elif rmodel!=255 or gmodel!=255 or bmodel!=255:
       rrr=int((1.2*rpixel-45))
       ggg=int((1.2*gpixel-45))
       bbb=int((1.2*bpixel-45))
       im.putpixel((i,j),(rrr,ggg,bbb)     
                 
    im.save('end.bmp')
    im.show()
  • bvdet
    Recognized Expert Specialist
    • Oct 2006
    • 2851

    #2
    That error often indicates a missing closing parenthesis. A missing closing parenthesis is causing your error.

    Comment

    • Oralloy
      Recognized Expert Contributor
      • Jun 2010
      • 988

      #3
      lines 15 and 20 need closing parentheses.

      Cheers!
      Oralloy

      Comment

      Working...