diff options
author | Daniel Friesel <derf@finalrewind.org> | 2021-04-23 19:17:21 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2021-04-23 19:17:21 +0200 |
commit | 7a8d2dde13b51dbefd99b5c45e0294a6b7486d7f (patch) | |
tree | 5b53ddc2120f399a6e65d4fb2c7331842c5e3b8d /bin | |
parent | d1d708002b860c92225e1e8c3a8a32def4c67c1a (diff) |
support non-jpeg / non-rgb files (e.g. GIFs)
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/pyggle | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -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 = """<div class="image-container">\n""" buf += f"""<a href="{filename}" class="glightbox" data-gallery="gallery1" data-description=".gdesc{index}">""" - buf += f"""<img src=".thumbnails/{filename}" alt="{filename}" />""" + buf += f"""<img src="{thumbname}" alt="{filename}" />""" buf += "</a>" buf += "</div>" buf += f"""<div class="glightbox-desc gdesc{index}">\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() |