From 69fa5bb7c51e66bcef7841536f1a04d3feb26485 Mon Sep 17 00:00:00 2001 From: dickreckard Date: Sun, 20 Oct 2019 23:53:59 +0200 Subject: [PATCH 1/2] thumbnails fix wrong indentation meant it never made the base64 thumbnails --- distribusi/distribusi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/distribusi/distribusi.py b/distribusi/distribusi.py index 313c67c..77a7a90 100644 --- a/distribusi/distribusi.py +++ b/distribusi/distribusi.py @@ -162,7 +162,7 @@ def distribusify(args, directory): # noqa caption = "" if args.captions: caption = caption(full_path) - a = FILE_TYPES[type_].format(name, caption) + a = FILE_TYPES[type_].format(name, caption) if subtype in SUB_TYPES: a = SUB_TYPES[subtype] From 49a521ea149a6ec28ddc228490416d11e59bb08b Mon Sep 17 00:00:00 2001 From: dickreckard Date: Mon, 21 Oct 2019 00:22:26 +0200 Subject: [PATCH 2/2] thumbnails png fix couldn't generate thumbnails for png pictures due to different mode (RGBA vs RGB) --- distribusi/distribusi.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/distribusi/distribusi.py b/distribusi/distribusi.py index 77a7a90..198e58d 100644 --- a/distribusi/distribusi.py +++ b/distribusi/distribusi.py @@ -33,6 +33,12 @@ def thumbnail(image, name, args): size = (450, 450) im = Image.open(image) im.thumbnail(size) + + if (im.mode == 'RGBA'): + bg = Image.new('RGBA', im.size, (255,255,255)) + composite = Image.alpha_composite(bg, im) + im=composite.convert('RGB') + output = BytesIO() im.save(output, format='JPEG') im_data = output.getvalue()