def thumbnail(self): if self.thumbnail_file.grid_id is None: img = self.image thumbnail_img = img.scale(140.0 / img.height) img_data = StringIO() thumbnail_img.save(img_data, "jpeg", quality = 25) self.thumbnail_file.put(img_data.getvalue(), content_type='image/jpeg') else: self.thumbnail_file.get().seek(0,0) thumbnail_img = Image(pil.open(StringIO(self.thumbnail_file.read()))) return thumbnail_img
def thumbnail(self): if self.thumbnail_file is None or self.thumbnail_file.grid_id is None: img = self.image thumbnail_img = img.scale(140.0 / img.height) if self.id and not "is_slave" in Session().mongo: img_data = StringIO() thumbnail_img.save(img_data, "jpeg", quality=75) self.thumbnail_file.put(img_data.getvalue(), content_type="image/jpeg") self.save() else: self.thumbnail_file.get().seek(0, 0) thumbnail_img = Image(pil.open(StringIO(self.thumbnail_file.read()))) return thumbnail_img
def image(self): if self._imgcache != '': return self._imgcache if self.clip_id is not None: return self.clip.images[self.clip_frame] self.imgfile.get().seek(0,0) #hackity hack, make sure the FP is at 0 if self.imgfile and self.imgfile.grid_id != None: try: self._imgcache = Image(pil.open(StringIO(self.imgfile.read()))) except (IOError, TypeError): # pragma no cover self._imgcache = None else: # pragma no cover self._imgcache = None return self._imgcache
def image(self): if self._imgcache != '': return self._imgcache self.imgfile.get().seek(0,0) #hackity hack, make sure the FP is at 0 if self.imgfile != None: try: self._imgcache = Image(pil.open(StringIO(self.imgfile.read()))) except (IOError, TypeError): # pragma no cover self._imgcache = None else: # pragma no cover self._imgcache = None if self.layerfile: self.layerfile.get().seek(0,0) self._imgcache.dl()._mSurface = pygame.image.fromstring(self.layerfile.read(), self._imgcache.size(), "RGBA") return self._imgcache