Mercurial > libervia-backend
comparison src/plugins/plugin_xep_0054.py @ 570:bf1505df088c
plugin XEP-0054: fixed bad image resizing
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 07 Jan 2013 23:08:45 +0100 |
parents | 0bb2e0d1c878 |
children | ca13633d3b6b |
comparison
equal
deleted
inserted
replaced
569:06faf5bffbc0 | 570:bf1505df088c |
---|---|
230 if not os.path.exists(filename): | 230 if not os.path.exists(filename): |
231 error (_("Asking for an uncached avatar [%s]") % avatar_hash) | 231 error (_("Asking for an uncached avatar [%s]") % avatar_hash) |
232 return "" | 232 return "" |
233 return filename | 233 return filename |
234 | 234 |
235 def _buildSetAvatar(self, vcard_set, filepath): | 235 def _buildSetAvatar(self, vcard_set, filepath): |
236 try: | 236 try: |
237 img = Image.open(filepath) | 237 img = Image.open(filepath) |
238 except IOError: | 238 except IOError: |
239 raise exceptions.DataError("Can't open image") | 239 raise exceptions.DataError("Can't open image") |
240 | 240 |
241 if img.size != (64, 64): | 241 if img.size != (64, 64): |
242 img.resize((64, 64)) | 242 img = img.resize((64, 64)) |
243 img_buf = StringIO() | 243 img_buf = StringIO() |
244 img.save(img_buf, 'PNG') | 244 img.save(img_buf, 'PNG') |
245 | 245 |
246 vcard_elt = vcard_set.addElement('vCard', NS_VCARD) | 246 vcard_elt = vcard_set.addElement('vCard', NS_VCARD) |
247 photo_elt = vcard_elt.addElement('PHOTO') | 247 photo_elt = vcard_elt.addElement('PHOTO') |