[Tutor] Questions about PIL

Luke Paireepinart rabidpoobear at gmail.com
Thu Nov 9 08:38:06 CET 2006


Chris Hengge wrote:
> Thanks for the detailed examples again Luke. Sorry I wasn't more clear 
> with my implimentation. The loop I was refering to was the one in the 
> start of my post but using im.tostring() instead. I saw an example to 
> make a webcam motion detector that used tostring(), but couldn't get 
> the program to see a difference.
I'm glad the examples helped.
See my other response about your use of the term 'loop.'
>
> As for just capturing a section of the screen. I'm not looking to make 
> faster captures, so I think your sample was on the ball. Your example 
> however wasn't quite what I had in mind when I was thinking up the 
> question and again I take fault for this. I was thinking more of a way 
> to create quadrants of the screenshot. (Or any number of area's) that 
> I could independantly interact with. I know this isn't a CPU friendly 
> task, but just humor me please =P 
Once again, you're not being explicit enough in explaining what you're 
trying to do.
Specifically, your sentence "(Or any number of area's) that I could 
independently interact with"
How are you trying to interact with them?
Do you want them split into actual separate image files, into separate 
image objects, or what?
The crop method I showed you will do any kind of splitting you want,
you just have to think through what exactly you need to crop in any 
given situation.
For example,
(pseudocode)

width = 1024/2
height = 768/2
image = load_image('imagename')
quad1 = image.crop((0,0,width,height))
quad2 = image.crop((width,0,width,height))
quad3 = image.crop((0,height,width,height))
quad4 = image.crop((width,height,width,height))

note that width and height are the w/h of the quadrants, not of the 
image itself.
since there are 4 quadrants (get it? quad = 4 ;)
each width/height would be original_image_<width or height> * (.5)

HTH,
-Luke


More information about the Tutor mailing list