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 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): """ Save the image to the cache if not cached yet. """ if settings.SIMPLETHUMB_CACHE_ENABLED: cached_image = self.cached if cached_image: return cached_image self.process_image() # Store the image data in cache image_str = BytesIO() self.pil.save(image_str, self.image_format, **self.save_params) image_data = image_str.getvalue() if settings.SIMPLETHUMB_CACHE_ENABLED: image_cache.set(self.cache_key, image_data) image_str.close() return image_data