diff options
author | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2013-08-26 05:18:10 +0000 |
---|---|---|
committer | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2013-08-26 05:18:10 +0000 |
commit | 98370267588204f878ba596c6c3bdf3ffc9c4d0c (patch) | |
tree | 8ffdecd1c4e5e257813374bf78c7ea6ac85aed84 /sca-cpp/trunk/hosting/server/pictures.py | |
parent | 2e5abd585874b18d5e94067ca7704a1966df3226 (diff) |
Improvements to the hosting management app server side logic.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1517420 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-cpp/trunk/hosting/server/pictures.py')
-rw-r--r-- | sca-cpp/trunk/hosting/server/pictures.py | 20 |
1 files changed, 2 insertions, 18 deletions
diff --git a/sca-cpp/trunk/hosting/server/pictures.py b/sca-cpp/trunk/hosting/server/pictures.py index 6c5e268e0f..fa953cdc24 100644 --- a/sca-cpp/trunk/hosting/server/pictures.py +++ b/sca-cpp/trunk/hosting/server/pictures.py @@ -16,32 +16,16 @@ # under the License. # Pictures collection implementation -from StringIO import StringIO -try: - from PIL import Image -except: - Image = None -from base64 import b64encode, b64decode from urllib import urlopen from util import * from atomutil import * +from imgutil import * from sys import debug # Convert a particular user id to a picture id def pictureid(id): return ('accounts', id, 'user.picture') -# Convert image to a 50x50 PNG image -def to50x50png(url): - debug('pictures.py::to50x50png::url', url) - if Image is None: - return url - img = Image.open(StringIO(b64decode(url.split(',')[1])) if url.startswith('data:') else StringIO(urlopen(url).read())) - t = img.resize((50, 50)) - obuf = StringIO() - t.save(obuf, 'PNG') - return 'data:image/png;base64,' + b64encode(obuf.getvalue()).replace('\n', '') - # Update the user's picture def put(id, picture, user, cache): debug('pictures.py::put::id', id) @@ -57,7 +41,7 @@ def put(id, picture, user, cache): # Get image and token from input picture def image(c): img = assoc("'image", c) - return None if isNull(img) else to50x50png(cadr(img)) + return None if isNull(img) else urlto50x50jpeg(cadr(img)) def token(c): tok = assoc("'token", c) return None if isNull(tok) else cadr(tok) |