473,799 Members | 3,638 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to fix if-elif-else syntax error?

8 New Member
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
2 3529
bvdet
2,851 Recognized Expert Moderator Specialist
That error often indicates a missing closing parenthesis. A missing closing parenthesis is causing your error.
Feb 8 '11 #2
Oralloy
988 Recognized Expert Contributor
lines 15 and 20 need closing parentheses.

Cheers!
Oralloy
Feb 8 '11 #3

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

Similar topics

3
17361
by: Andy Levy | last post by:
Hi Im trying to create a function that tests if a 'Username' exists in a particular table. If the value is found then the code generates 'Username1' as the username, and check if that username exists. If it does, it continues onto generating 'Username2' and so on. <? //testing with username andrew $name = "andrew";
4
10192
by: Randell D. | last post by:
Folks, I test if my PHP should process form data by checking if $_POST is an array - However I always find its condition proves true - Why or alternatvily, what other method can one use to check for this sort of situation? <? if(is_array($_POST)) { die("<h1>here</h1>"); }
3
3398
by: Smriti Dev | last post by:
Hi there, I have the following code: echo "\n <address>"; if ($entry_info and $entry_info != '') { echo "\n ".stripslashes($entry_info).".,"; } if ($entry_info and $entry_info != '' ) { echo "\n ".stripslashes($entry_info);
3
4045
by: Eric Linders | last post by:
Hello, We have a form that is collecting user input. There are three fields for each phone number (area code, prefix and suffix). I'm trying to use a simple if statement to confirm if the first character in any of the fields is "0". If it is, then I just redirect them to a different page because it's someone that is just messing around. Unfortunately, whenever the form loads, the if statement automatically evaluates to true and the user...
5
2093
by: Lars Plessmann | last post by:
I have a problem with typecast methods. Here is a setter of an object: function setKind($kind) { if (is_int((int)$kind) and (strlen($kind)<=6)) { $this->kind = $kind; return true;
4
108455
by: Tristan | last post by:
Is there any support for a negative condition in If statements in PHP. Some tutorials ive found say that you can use the if!(condition)cmd; syntax. however i always get an error when i use that. "Parse error: parse error, unexpected '!', expecting '(' in TMP5rsqwh3ag.php on line 13" I am runing PHP 4.3.2.
5
1676
by: Jack | last post by:
I'm setting up a form and want to check if some conditions are met when the form submits. If they aren't, the form displays a missing field message and the user has to go back to fill in the missing data. If it is met, the form continues processing. I have the $state variable coming from a drop down SELECT option with "" being the SELECTED default. The if statements are included inside the form tags on the form page, not on the...
32
33074
by: Nuno Paquete | last post by:
Hi group. I'm using this code to see if is there any parameter for variable "menu": if($_GET == "downloads") .... But this code log errors if there is no parameter passed (this heappens at the first time the page is loaded). I tryed this code:
4
1621
by: Maxim Vexler | last post by:
if ((($value1 != null) || ($value1 != "")) && $value2 != "" && $value1 != $value2) { ret false } if i omit the i would still get the same result, right? because I check if value1 != "" and then I check if value1!=value2 i.e. : if ((($value1 != null) || ($value1 != "")) && $value1 != value2) { ret false }
4
11123
by: lawrence | last post by:
Google can't find me a good example of how to use the "if exists" syntax in MySql. Is it right that to use it this way: INSERT INTO IF EXISTS tMyTable VALUES("xxlk", "lkjlkjlkjljk") I want to insert into a table but only if the table exists. How does one, in general, from PHP, test for the existence of a table, without getting an error message?
0
9687
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9541
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10485
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10231
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10027
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6805
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5463
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4141
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2938
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.