By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,957 Members | 2,017 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,957 IT Pros & Developers. It's quick & easy.

How to fix if-elif-else syntax error?

P: 8
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:
Expand|Select|Wrap|Line Numbers
  1. import Image,math
  2. model = Image.open("model.jpg")
  3. test = Image.open("test.jpg")
  4. x=test.size[0]
  5. y=test.size[1]
  6. im  = Image.new("RGB",(x,y))
  7.  
  8. for i in range(300):
  9.  for j in range(300):
  10.  
  11.   rpixel,gpixel,bpixel=test.getpixel((i,j))
  12.   rmodel,gmodel,bmodel=model.getpixel((i,j))
  13.  
  14.   if 255==rmodel and 255==gmodel and 255==bmodel:
  15.    im.putpixel((i,j),(rpixel,gpixel,bpixel)
  16.   elif rmodel!=255 or gmodel!=255 or bmodel!=255:
  17.    rrr=int((1.2*rpixel-45))
  18.    ggg=int((1.2*gpixel-45))
  19.    bbb=int((1.2*bpixel-45))
  20.    im.putpixel((i,j),(rrr,ggg,bbb)     
  21.  
  22. im.save('end.bmp')
  23. im.show() 
  24.  
Feb 8 '11 #1
Share this Question
Share on Google+
2 Replies


bvdet
Expert Mod 2.5K+
P: 2,851
That error often indicates a missing closing parenthesis. A missing closing parenthesis is causing your error.
Feb 8 '11 #2

Oralloy
Expert 100+
P: 983
lines 15 and 20 need closing parentheses.

Cheers!
Oralloy
Feb 8 '11 #3

Post your reply

Sign in to post your reply or Sign up for a free account.