if res:
return bytes(res.data)
- async def get_thumbnail(self, size):
+ async def get_thumbnail(self, size, format=None):
assert self.is_bitmap_image()
- cache_key = "-".join((
+ cache_key = ":".join((
+ "wiki",
+ "thumbnail",
self.path,
util.normalize(self.filename),
self.created_at.isoformat(),
+ format or "N/A",
"%spx" % size,
))
return thumbnail
# Generate the thumbnail
- thumbnail = util.generate_thumbnail(self.blob, size)
+ thumbnail = util.generate_thumbnail(self.blob, size, format=format)
# Put it into the cache for forever
await self.backend.cache.set(cache_key, thumbnail)