def get(self, f, file_name="", width=None, height=None): width = width or self.width height = height or self.height image = Image.open(f) image.thumbnail((width, height), Image.ANTIALIAS) thumb = StringIO() image.save(thumb, "png") thumb.seek(0) return thumb
def get(self, f, file_name='', width=None, height=None): width = width or self.width height = height or self.height image = Image.open(f) image.thumbnail((width, height), Image.ANTIALIAS) thumb = StringIO() image.save(thumb, 'png') thumb.seek(0) return thumb
def get(self, f, file_name="", width=None, height=None): # ZipFile requires seek: if not isinstance(f, basestring) and not hasattr(f, "seek"): d = StringIO() shutil.copyfileobj(f, d) d.seek(0) f = d # Extract: 'Thumbnails/thumbnail.png' png = StringIO(zipfile.ZipFile(f, "r").read("Thumbnails/thumbnail.png", "r")) return super(OfficeBackend, self).get(png, width=width, height=height)
def get(self, f, file_name='', width=None, height=None): # ZipFile requires seek: if not isinstance(f, basestring) and not hasattr(f, 'seek'): d = StringIO() shutil.copyfileobj(f, d) d.seek(0) f = d # Extract: 'Thumbnails/thumbnail.png' png = StringIO(zipfile.ZipFile(f, 'r').read('Thumbnails/thumbnail.png', 'r')) return super(OfficeBackend, self).get(png, width=width, height=height)
class OutputStream(Base, XOutputStream): """A simple stream that is compatible with UNO XOutputStream and can also return a StringIO object containing what was written to it.""" def __init__(self): self.closed = 0 self.stream = StringIO() def closeOutput(self): self.closed = 1 def writeBytes(self, seq): self.stream.write(seq.value) def getStream(self): self.stream.seek(0) return self.stream def flush(self): pass
class OutputStream( Base, XOutputStream ): """A simple stream that is compatible with UNO XOutputStream and can also return a StringIO object containing what was written to it.""" def __init__(self): self.closed = 0 self.stream = StringIO() def closeOutput(self): self.closed = 1 def writeBytes(self, seq): self.stream.write(seq.value) def getStream(self): self.stream.seek(0) return self.stream def flush(self): pass