473,657 Members | 2,654 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

help with this loop

Thekid
145 New Member
I need help writing a loop for this.
Expand|Select|Wrap|Line Numbers
  1. image = ImageGrab.grab((0,0,800,800))
  2. box = (100,100,400,400)
  3. im = image.crop(box)
  4. im1 = im.save("screen.jpg")
  5. # at this point I need to rotate the image 90 degrees and crop it again, but do this four times-
  6. # so I'd like a loop here instead of this:
  7. im2 = im1.rotate(90)
  8. im3 = im2.crop(box)
  9. im4 = im3.save("screen1.jpg")
  10. im5 = im4.rotate(90)
  11. im6 = im5.crop(box)
  12. im7 = im6.save("screen2.jpg")
  13. im8=im7.rotate(90)
  14. im9=im8.crop(box)
  15. im10=im9.save("screen3.jpg")
  16. # I did try something like this:
  17. # for i in range(3):
  18. #       im,im1,im2
  19. #but that doesn't work
  20.  
any help?
Nov 5 '08 #1
3 1470
bvdet
2,851 Recognized Expert Moderator Specialist
If you don't need to save any intermediate results, maybe something like this:
Expand|Select|Wrap|Line Numbers
  1. for i in range(1, 4):
  2.     im1.rotate(90).crop(box).save("screen%s.jpg" % i)
Nov 6 '08 #2
bvdet
2,851 Recognized Expert Moderator Specialist
I thought about it some more, and the code I suggested will only work if the methods modify the image object "in place". I am not so sure whether or not the save method returns an image object, but it probably does not modify the object. Here's the loop again, slightly modified:
Expand|Select|Wrap|Line Numbers
  1. for i in range(1, 4):
  2.     im1 = im1.rotate(90).crop(box)
  3.     im1.save("screen%s.jpg" % i)
Nov 6 '08 #3
Thekid
145 New Member
This looks good but when I try it the image will only rotate one time and then the jpg is saved 3 times.
Nov 6 '08 #4

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

Similar topics

3
5943
by: William Buchanan | last post by:
Hi I have the following stored proc in interbase (which might contain errors - i'm doing it off the top of my head), which I would like to convert into oracle. Can you help? What I want back is a dataset of all the records where Ch_Val is different to the previous value. Thanks for any help. create procedure GetChanges(StartDate timestamp, EndDate timestamp)
21
1362
by: cjl | last post by:
Hey all: I have the following (ugly) code: function preload() { if (cr_series.length >1) preloadCR(); if (ct_series.length >1) preloadCT(); if (mr_series.length >1) preloadMR(); if (us_series.length >1) preloadUS();
23
3259
by: Jason | last post by:
Hi, I was wondering if any could point me to an example or give me ideas on how to dynamically create a form based on a database table? So, I would have a table designed to tell my application to create certain textboxes, labels, and combo boxes? Any ideas would be appreciated. Thanks
1
6075
by: al2004 | last post by:
Write a program that reads information about youth soccer teams from a file, calculates the average score for each team and prints the averages in a neatly formatted table along with the team name. Please follow the specifications for assignment 3 as described below otherwise points will be taken off. Input from a file Please create an input file named input.txt using a text editor like notepad or the Visual C++ editor and put the following...
1
6121
by: trunxnirvana007 | last post by:
'UPGRADE_WARNING: Array has a new behavior. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"' 'UPGRADE_WARNING: Couldn't resolve default property of object Label. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"' Label = New Object(){Box1, Box2, Box3, Box4, Box5, Box6, Box7, Box8, Box9, Box10, Box11,...
9
1903
by: TF | last post by:
Hello all, I made a ASP.NET 2.0 site that shows possible "recipes" for paint colors stored in an access dbase. Basically, 1000 colors are stored with specific RGB values in separate columns. A user sees all the colors listed on the page with hyperlinks that open the "mixes" page. The mixes page goes through each record, compares it with all other records in a ratio up to "maxratio". If it finds a ratio that matches the redvalue of...
6
3310
by: jenipriya | last post by:
Hi all... its very urgent.. please........i m a beginner in oracle.... Anyone please help me wit dese codes i hv tried... and correct the errors... The table structures i hav Employee (EmpID, EmpName,DeptID,DateOfJoin, Sal, Addr) Finance (EmpID, Sal) Club (Clubname, EmpID, Fee, DateOfJoin) Leave (EmpID, Date) Department (DeptID, DeptName, NoOfEmployees)...
0
6535
by: shrik | last post by:
I have following error : Total giant files in replay configuration file are : File name : /new_file/prob1.rec Given file /new_file/prob1.rec is successfully verified. Splitting for giant file /new_file/prob1.rec started. Please wait.... In while loop of request searching *** glibc detected *** ./a.out: free(): invalid next size (normal): 0x099da890 *** ======= Backtrace: ========= /lib/libc.so.6
41
2671
by: c | last post by:
Hi every one, Me and my Cousin were talking about C and C#, I love C and he loves C#..and were talking C is ...blah blah...C# is Blah Blah ...etc and then we decided to write a program that will calculate the factorial of 10, 10 millions time and print the reusult in a file with the name log.txt.. I wrote something like this
1
2004
by: mshroom12 | last post by:
Hello to all. I am having difficulty trying to do this Java project using Eclipse. The following is what I have to do. Election Day It's almost election day and the election officials need a program to help tally election results. There are two candidates for office -- Polly Tichen and Ernest Orator. The program's job is to take as input the number of votes each candidate received in each voting precinct and find the total number of votes for...
0
8394
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
8825
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...
0
8732
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8605
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
7327
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6164
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4152
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...
0
4304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
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

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.