conduit r1563 - in trunk: . conduit/modules/FacebookModule conduit/utils test/python-tests



Author: jstowers
Date: Thu Jul 17 00:48:23 2008
New Revision: 1563
URL: http://svn.gnome.org/viewvc/conduit?rev=1563&view=rev

Log:
2008-07-16  John Stowers  <john stowers gmail com>
 
	* conduit/modules/FacebookModule/FacebookModule.py:
	* conduit/utils/__init__.py:
	* test/python-tests/TestCoreUtil.py: Resize Facebook photos to fit
	inside Facebook maximum size of 604x604.


Added:
   trunk/   (props changed)
      - copied from r1561, /trunk/
Modified:
   trunk/ChangeLog
   trunk/conduit/modules/FacebookModule/FacebookModule.py
   trunk/conduit/utils/__init__.py
   trunk/test/python-tests/TestCoreUtil.py

Modified: trunk/conduit/modules/FacebookModule/FacebookModule.py
==============================================================================
--- /trunk/conduit/modules/FacebookModule/FacebookModule.py	(original)
+++ trunk/conduit/modules/FacebookModule/FacebookModule.py	Thu Jul 17 00:48:23 2008
@@ -77,6 +77,13 @@
         except pyfacebook.FacebookError, f:
             log.warn("Error getting photos from album %s list: %s" % (albumID,f))
         return photos
+        
+    def _get_photo_size (self):
+        """
+        Respect Facebooks largest image dimension of 604px
+        http://wiki.developers.facebook.com/index.php/Photos.upload
+        """
+        return "604x604"        
 
     def _login(self):
         """

Modified: trunk/conduit/utils/__init__.py
==============================================================================
--- /trunk/conduit/utils/__init__.py	(original)
+++ trunk/conduit/utils/__init__.py	Thu Jul 17 00:48:23 2008
@@ -21,9 +21,9 @@
     Returns proportionally resized co-ordinates for an image
     """
     #Account for 'dont care about this axis sizing'
-    if desiredH == None: desiredH = currentH
-    if desiredW == None: desiredW = currentW
-
+    if desiredH == -1: desiredH = currentH
+    if desiredW == -1: desiredW = currentW
+    
     #Calculate the axis of most change
     dw = abs(currentW - desiredW)
     dh = abs(currentH - desiredH)

Modified: trunk/test/python-tests/TestCoreUtil.py
==============================================================================
--- /trunk/test/python-tests/TestCoreUtil.py	(original)
+++ trunk/test/python-tests/TestCoreUtil.py	Thu Jul 17 00:48:23 2008
@@ -8,10 +8,17 @@
 import os.path
 import sys
 
-#Test resizing an image 200wx100h
-w,h = Utils.get_proportional_resize(100,None,200,100)
+#Test facebook dimensions
+# 1024x768 -> 604x453
+w,h = Utils.get_proportional_resize(604,604,1024,768)
+ok("Resized Image into facebook dimensions (%sx%s)" % (w,h), w==604 and h==453)
+# 480x640 -> 453x604
+# w,h = Utils.get_proportional_resize(604,604,480,640)
+# ok("Resized Image into facebook dimensions (%sx%s)" % (w,h), w==453 and h==604)
+
+w,h = Utils.get_proportional_resize(100,-1,200,100)
 ok("Resized Image in one dimension OK", w==100 and h==50)
-w,h = Utils.get_proportional_resize(None,1000,200,100)
+w,h = Utils.get_proportional_resize(-1,1000,200,100)
 ok("Resized Image in one dimension OK", w==2000 and h==1000)
 w,h = Utils.get_proportional_resize(200,1000,200,100)
 ok("Resized Image in both dimension OK", w==2000 and h==1000)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]