Make the gallery extension work on colab

This commit is contained in:
oobabooga 2023-02-26 12:37:26 -03:00
parent 756cba2edc
commit 3333f94c30
2 changed files with 28 additions and 12 deletions

View file

@ -200,7 +200,7 @@ def image_to_base64(path):
if (path in image_cache and mtime != image_cache[path][0]) or (path not in image_cache):
img = Image.open(path)
img.thumbnail((100, 100))
img.thumbnail((200, 200))
img_buffer = BytesIO()
img.convert('RGB').save(img_buffer, format='PNG')
image_cache[path] = [mtime, base64.b64encode(img_buffer.getvalue()).decode("utf-8")]