Skip to content

Commit

Permalink
fix(Proofs): fix thumbnail generation for some JPEG images. ref #486
Browse files Browse the repository at this point in the history
  • Loading branch information
raphodn committed Oct 3, 2024
1 parent aff057b commit a7f18e9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion open_prices/proofs/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ def generate_thumbnail(
image_thumb_full_path = generate_full_path(
current_dir, f"{file_stem}.{settings.THUMBNAIL_SIZE[0]}", extension
)
img_thumb.save(image_thumb_full_path) # exif will be stripped
# avoid 'cannot write mode RGBA as JPEG' error
if mimetype in ("image/jpeg",) and img_thumb.mode in ("RGBA", "P"):
img_thumb = img_thumb.convert("RGB")
# save (exif will be stripped)
img_thumb.save(image_thumb_full_path)
image_thumb_path = generate_relative_path(
current_dir_id_str,
f"{file_stem}.{settings.THUMBNAIL_SIZE[0]}",
Expand Down

0 comments on commit a7f18e9

Please sign in to comment.