Skip to content

Commit

Permalink
Allow for url uploads
Browse files Browse the repository at this point in the history
  • Loading branch information
VirginiaDooley committed Apr 12, 2023
1 parent d44bad0 commit 5ab256a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion ynr/apps/moderation_queue/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,13 @@ def convert_image_to_png(photo):
# Some uploaded images are CYMK, which gives you an error when
# you try to write them as PNG, so convert to RGBA (this is
# RGBA rather than RGB so that any alpha channel (transparency)
# is preserved).
# is preserved). At this point, the photo being passed is an opened
# PillowImage object

# if the photo was a url upload and is not a PillowImage object,
# convert it to a PillowImage object before converting
if not isinstance(photo, PillowImage.Image):
photo = PillowImage.open(photo)
converted = photo.convert("RGBA")
bytes_obj = BytesIO()
converted.save(bytes_obj, "PNG")
Expand Down

0 comments on commit 5ab256a

Please sign in to comment.