473,385 Members | 1,569 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

PIL implementation

I wrote this snippet with the intention of -- capturing a section of
the screen whenever it changes. It could be implemented to log any
sort of messaging system ( by saving consecutive images eg.
1.png...etc).

#code --------------------

import Image
import ImageGrab
lastchatbound = (21, 504) + (189, 516)
img1 = ImageGrab.grab(lastchatbound)
data1 = list(img1.getdata())
img2 = ImageGrab.grab(lastchatbound)
data2 = list(img2.getdata())
# print `data1`
if data1 != data2:
img1.save(`picnumber` + '.png')
picnumber = picnumber + 1
else:
print "same"

#code ------------------

it doesn't work yet and i'm not quite sure how the loops work yet ( i
just sarted python last week). any help anyone could give me would be
appreciated.

if someone could rewrite it so it works, i could use that as an example
for the future, thanks.

- mb

Jan 7 '06 #1
4 1664
circusdei wrote:
I wrote this snippet with the intention of -- capturing a section of
the screen whenever it changes. It could be implemented to log any
sort of messaging system ( by saving consecutive images eg.
1.png...etc).

#code --------------------

import Image
import ImageGrab
lastchatbound = (21, 504) + (189, 516)
img1 = ImageGrab.grab(lastchatbound)
data1 = list(img1.getdata())
img2 = ImageGrab.grab(lastchatbound)
data2 = list(img2.getdata())
# print `data1` pictnumber = 0 if data1 != data2:
img1.save(`picnumber` + '.png')
picnumber = picnumber + 1
else:
print "same"

#code ------------------

it doesn't work yet and i'm not quite sure how the loops work yet ( i
just sarted python last week). any help anyone could give me would be
appreciated.

if someone could rewrite it so it works, i could use that as an example
for the future, thanks.

- mb

At the first glance the code looks almost ok. It is a good habit always
to attach documentation of the error messages if any.
What I can directly see is, that you need at least to initialize the
picnumber (see above).
Look in the Python documentation for the chapter with loops, read about
the time module you will need to let the loop pause before taking the
next screenshot and consider also, that maybe later it would be a good
idea to have a way to stop the loop executing.
Come back with the next revision of your code for further help if you
get into trouble or wait until someone else provides you with
appropriate working code.

Claudio
Jan 7 '06 #2
The error message is --> "Syntax error" and it highlights the last
"else" statement.

Jan 9 '06 #3
The error message is --> "Syntax error" and it highlights the last
"else" statement.

thanks for the reply.

Jan 9 '06 #4
arkestra wrote:
The error message is --> "Syntax error" and it highlights the last
"else" statement.


You've got incorrect indentation, at least judging by what I see in my
newsreader (Thunderbird), which clearly shows the else indented more
than the corresponding if.

Next time, please cut and paste the *actual* error message instead of
retyping and paraphrasing. That will get you a faster answer and save
us lots of annoying guessing.

Jan 10 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: jenniferyiu | last post by:
IMHO, simply NO. False actually, practically.
9
by: Anon Email | last post by:
Hi people, I'm learning about header files in C++. The following is code from Bartosz Milewski: // Code const int maxStack = 16; class IStack
29
by: Enrico `Trippo' Porreca | last post by:
Both K&R book and Steve Summit's tutorial define a getline() function correctly testing the return value of getchar() against EOF. I know that getchar() returns EOF or the character value cast to...
52
by: lovecreatesbeauty | last post by:
Why the C standard committee doesn't provide a standard implementation including the C compiler and library when the language standard document is published? C works on the abstract model of low...
20
by: Luc Kumps | last post by:
(Sorry about the previous post, it got transmitted before it was complete) We try to separate implementation and interface defintions, but we run into a problem. I hope the guru's can solve this,...
7
by: desktop | last post by:
I the C++ standard page 472 it says that an associative container can be constructed like X(i,j,c) where i and j are input iterators to elements. But in the implementation there is no constructor...
6
by: Ralph | last post by:
Hi, I was reading effictive C++ and some other books again and they all tell you about hiding implementation details (proxy/pimpl/inheritance) but they never really explain when to use it. I...
0
by: anto.anish | last post by:
Hi , Since, i did not want to write instantiations in Source file of all template methods for various different datatypes that my client might use, i choose to write implementation of template...
1
by: anto.anish | last post by:
Hi , Since, i did not want to write explicit instantiations in Source file of all template methods for various different datatypes that my client might use, i choose to write implementation of...
173
by: Ron Ford | last post by:
I'm looking for a freeware c99 compiler for windows. I had intended to use MS's Visual C++ Express and use its C capability. In the past with my MS products, I've simply needed to make .c the...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.