From 7a8d2dde13b51dbefd99b5c45e0294a6b7486d7f Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Fri, 23 Apr 2021 19:17:21 +0200 Subject: support non-jpeg / non-rgb files (e.g. GIFs) --- bin/pyggle | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'bin') diff --git a/bin/pyggle b/bin/pyggle index b3b89ec..e7418b5 100755 --- a/bin/pyggle +++ b/bin/pyggle @@ -167,10 +167,10 @@ def copy_files(base_dir): f.write(main_css) -def create_thumbnail_html(index, filename, title): +def create_thumbnail_html(index, thumbname, filename, title): buf = """
\n""" buf += f"""""" - buf += f"""{filename}""" + buf += f"""{filename}""" buf += "" buf += "
" buf += f"""
\n""" @@ -226,9 +226,15 @@ if __name__ == "__main__": im = rotate_image(im, exif_tag) im.thumbnail((args.size * 2, args.size * 2)) - im.save(f".thumbnails/{filename}", "JPEG") - html_buf += create_thumbnail_html(i, filename, format_exif(exif_tag)) + thumbname = f".thumbnails/{filename}" + + if not filename.lower().endswith((".jpeg", ".jpg")): + thumbname += ".jpg" + + im.convert("RGB").save(thumbname, "JPEG") + + html_buf += create_thumbnail_html(i, thumbname, filename, format_exif(exif_tag)) with open(f"{base_dir}/share/html_end", "r") as f: html_buf += f.read() -- cgit v1.2.3