473,671 Members | 2,261 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PIL question about crop method

I might be way off target even looking into this method for what I need
to do, but I'm still a little confused about the description of it:

crop
im.crop(box) => image

Returns a rectangular region from the current image. The box is a
4-tuple defining the left, upper, right, and lower pixel coordinate.

I'm probably just being a little dense again, but how exactly do you
write the tuple? Wouldn't a coordinates parameter be a tuple of tuples?
It sounds like here you only need four numbers, but I don't understand
what 'left, upper, right, and lower pixel coordinate' means. It doesn't
seem like it's asking for a set of coordinates for each corner of the
box, or for a set at all. How do four separate numbers make up coordinates?

Thanks.
Apr 5 '06 #1
6 8604
John Salerno schrieb:
I might be way off target even looking into this method for what I need
to do, but I'm still a little confused about the description of it:

crop
im.crop(box) => image

Returns a rectangular region from the current image. The box is a
4-tuple defining the left, upper, right, and lower pixel coordinate.

I'm probably just being a little dense again, but how exactly do you
write the tuple? Wouldn't a coordinates parameter be a tuple of tuples?
It sounds like here you only need four numbers, but I don't understand
what 'left, upper, right, and lower pixel coordinate' means. It doesn't
seem like it's asking for a set of coordinates for each corner of the
box, or for a set at all. How do four separate numbers make up coordinates?


You can think of a rect as two coordinates - e.g. (10, 20), (30, 100)

Alternatively you can see it as boundary lines, in the order left, top,
right, bottom.

(10, 20, 30, 100)

The latter is what you need.

Diez
Apr 5 '06 #2
John Salerno wrote:
I might be way off target even looking into this method for what I need
to do, but I'm still a little confused about the description of it:

crop
im.crop(box) => image

Returns a rectangular region from the current image. The box is a
4-tuple defining the left, upper, right, and lower pixel coordinate.

I'm probably just being a little dense again, but how exactly do you
write the tuple? Wouldn't a coordinates parameter be a tuple of tuples?
It sounds like here you only need four numbers, but I don't understand
what 'left, upper, right, and lower pixel coordinate' means. It doesn't
seem like it's asking for a set of coordinates for each corner of the
box, or for a set at all. How do four separate numbers make up coordinates?

Thanks.

If you want the cropped rectangle to go from 100 to 200 in x and 300 to
400 in y, then those four values need to be placed in a tuple in the
specified order:
box=(100,300,20 0,400)

Gary Herron

Apr 5 '06 #3
Diez B. Roggisch wrote:
Alternatively you can see it as boundary lines, in the order left, top,
right, bottom.

(10, 20, 30, 100)


So in the above, from where are the numbers being counted? 10 is ten
pixels from the left border of the image? 20 is twenty pixels from the
top border? But is 30 thirty pixels from the left or the right border of
the image? And is 100 one hundred pixels from the top or bottom?
Apr 5 '06 #4
John Salerno wrote:
Diez B. Roggisch wrote:
Alternatively you can see it as boundary lines, in the order left,
top, right, bottom.

(10, 20, 30, 100)


So in the above, from where are the numbers being counted? 10 is ten
pixels from the left border of the image? 20 is twenty pixels from the
top border? But is 30 thirty pixels from the left or the right border of
the image? And is 100 one hundred pixels from the top or bottom?


I came up with this, is it correct:

(a,b) (c,b)
-----------------
| |
| |
-----------------
(a,d) (c,d)
So the tuple would be (a, b, c, d)?
Apr 5 '06 #5
Yes


John Salerno wrote:
John Salerno wrote:
Diez B. Roggisch wrote:
Alternatively you can see it as boundary lines, in the order left,
top, right, bottom.

(10, 20, 30, 100)


So in the above, from where are the numbers being counted? 10 is ten
pixels from the left border of the image? 20 is twenty pixels from the
top border? But is 30 thirty pixels from the left or the right border of
the image? And is 100 one hundred pixels from the top or bottom?


I came up with this, is it correct:

(a,b) (c,b)
-----------------
| |
| |
-----------------
(a,d) (c,d)
So the tuple would be (a, b, c, d)?


Apr 5 '06 #6
John Salerno wrote:
John Salerno wrote:

Diez B. Roggisch wrote:
Alternativel y you can see it as boundary lines, in the order left,
top, right, bottom.

(10, 20, 30, 100)

So in the above, from where are the numbers being counted? 10 is ten
pixels from the left border of the image? 20 is twenty pixels from the
top border? But is 30 thirty pixels from the left or the right border of
the image? And is 100 one hundred pixels from the top or bottom?


I came up with this, is it correct:

(a,b) (c,b)
-----------------
| |
| |
-----------------
(a,d) (c,d)
So the tuple would be (a, b, c, d)?

That look right.

But why be so cautious? Try it and see if it works. (I believe it will
-- but if not -- try again.)

Gary Herron
Apr 5 '06 #7

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

Similar topics

5
9471
by: Kevin Smith | last post by:
Is there a way to "auto-crop" an image in PIL? I have some PNG images with white backgrounds that I want cropped to show only the non-white portion in the center, but I don't see how I can do this. -- Kevin Smith Kevin.Smith@sas.com
6
4982
by: isaacyho | last post by:
Is there a fast way to crop a vector? I have a vector of size n, and want to reduce it to some subregion (x,y ). Seems like you shouldn't have to recopy all of those elements into a new vector, since they are already contiguous in memory. Thanks, Isaac
1
1501
by: Jazper | last post by:
hi how can i Insert, change and crop META-Tags auf a Webform programmtechnically? Regards Jazper
3
8459
by: ACaunter | last post by:
Hi there, I was wondering if there was a way to crop a peice of an ASP.Net Image, allowing the user to zoom in on only a section of the picture?? any help would be appreciated!! thanks -- AdamPC@hotmail.com
4
13803
by: Crirus | last post by:
I have a square picture. I need to draw a circle on it, and everything outside that circle to be set to a certain color, so the image looks framed On other words, I want to crop a circle form a rectangular picture Any hints?
1
3297
by: arunbalait | last post by:
I want to crop an image in VB and to store the cropped image in another image box or any... I want source code samples
2
2840
by: sampath nslabs | last post by:
sir How to crop the image in visual basic 6.0.iam geting in vb.net but i want purelly in vb.plese give the code for that or give me useful snippts.i expecting source code for crop the image .pls any one can help me.
0
7236
by: brahimbb17 | last post by:
There is no foolproof way to always win when gambling http://crop-finder-for-travian.blogspot.com . That is why it’s called gambling, you take risks and reap the benefits when lady lucks sides by you, but this isn’t always the case. Most of the time people end up being addicted, losing all that they’ve worked for all in the belief that gambling is the real get rich quick solution. Gambling is addictive; therefore there is no real...
3
3779
by: fuchsia555 | last post by:
hi is there a code to crop bottom border from an image when creating thumbnail for this image without crop the original image , but just crop 15px bottom border for creating the thumbnails for the image ?
0
8476
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
8393
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,...
1
8598
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
8670
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...
1
6229
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
5696
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
4225
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
4407
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2051
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.