From 98370267588204f878ba596c6c3bdf3ffc9c4d0c Mon Sep 17 00:00:00 2001 From: jsdelfino Date: Mon, 26 Aug 2013 05:18:10 +0000 Subject: 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 --- sca-cpp/trunk/hosting/server/icons.py | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) (limited to 'sca-cpp/trunk/hosting/server/icons.py') diff --git a/sca-cpp/trunk/hosting/server/icons.py b/sca-cpp/trunk/hosting/server/icons.py index a7d63348b3..d13ab90a49 100644 --- a/sca-cpp/trunk/hosting/server/icons.py +++ b/sca-cpp/trunk/hosting/server/icons.py @@ -16,32 +16,15 @@ # under the License. # App icons 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 an id to an icon id def iconid(id): return ("apps", car(id), "app.icon") -# Convert image to a 50x50 PNG image -def to50x50png(url): - debug('icons.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', '') - # Put an icon def put(id, icon, user, cache, apps): debug('icons.py::put::id', id) @@ -61,7 +44,7 @@ def put(id, icon, user, cache, apps): # Get image and token from input icon 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) -- cgit v1.2.3