Skip to content

Commit

Permalink
fix: convert image to RGB after cropping if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
raphael0202 committed Dec 25, 2024
1 parent da3fbc5 commit 77ce5a4
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions robotoff/app/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -949,6 +949,9 @@ def on_get(self, req: falcon.Request, resp: falcon.Response):
def image_response(image: Image.Image, resp: falcon.Response) -> None:
resp.content_type = "image/jpeg"
fp = io.BytesIO()
# JPEG doesn't support RGBA, so we convert to RGB if needed
if image.mode != "RGB":
image = image.convert("RGB")
image.save(fp, "JPEG")
stream_len = fp.tell()
fp.seek(0)
Expand Down

0 comments on commit 77ce5a4

Please sign in to comment.