def save(self): """ Save the image to the cache if provided and not cached yet. """ if self.cache and not self.is_cached: image_str = StringIO.StringIO() self.pil.save(image_str, ext_to_format(self.cached_name)) self.cache.set(self.cached_name, image_str.getvalue()) image_str.close()
def save(self): """ Save the image to the cache if provided and not cached yet. """ if self.cache and not self.is_cached: image_str = BytesIO() self.pil.save(image_str, ext_to_format(self.cached_name)) self.cache.set(self.cached_name, image_str.getvalue()) image_str.close()
def render(self): """ Renders the file content """ if self.is_cached: return self.cache.get(self.cached_name) else: image_str = StringIO.StringIO() self.pil.save(image_str, ext_to_format(self.cached_name)) return image_str.getvalue()
def render(self): """ Renders the file content """ if self.is_cached: return self.cache.get(self.cached_name) else: image_str = BytesIO() self.pil.save(image_str, ext_to_format(self.cached_name)) return image_str.getvalue()