[Image-SIG] Patch to add .w and .h to Image objects.
C. Barnes
connellybarnes at yahoo.com
Wed Jun 23 18:07:10 EDT 2004
It's inconvenient to write im.size[0] and im.size[1]
everywhere. This is a patch to add .w and .h to the
Image class.
--- Image.bak Wed Jun 23 14:55:37 2004
+++ Image.py Wed Jun 23 14:55:39 2004
@@ -398,6 +398,13 @@
_makeself = _new # compatibility
+ w = property(__getw)
+ h = property(__geth)
+
+ def __getw(self): return self.size[0]
+ def __geth(self): return self.size[1]
+
+
def _copy(self):
self.load()
self.im = self.im.copy()
Pros:
1. im.w and im.h are more semantically descriptive.
2. im.w and im.h are simpler.
Cons:
1. More than one way to determine an image's
width/height.
However, I think the pros outweigh the cons.
By analogy, consider a vector in R^3.
It is convenient to be able to write either vec.x or
vec[0]. One is semantically superior, one is more
useful for loops. Thus I think that Images should
have both .size and .w/.h.
- Connelly
__________________________________
Do you Yahoo!?
Yahoo! Mail - Helps protect you from nasty viruses.
http://promotions.yahoo.com/new_mail
More information about the Image-SIG
mailing list