ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> image-sig
image-sig
[Image-SIG] Patch to add .w and .h to Image objects.
by C. Barnes other posts by this author
Jun 23 2004 10:07PM messages near this date
[Image-SIG] Re: PIL, popen, and GTK | [Image-SIG] $73221
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

_______________________________________________
Image-SIG maillist  -  Image-SIG@[...].org
http://mail.python.org/mailman/listinfo/image-sig

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved