Skip to content

Commit

Permalink
fix(ocr): convert images to RGB format before processing
Browse files Browse the repository at this point in the history
  • Loading branch information
c0deplayer committed Nov 22, 2024
1 parent e0fe69f commit dd42083
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/ocr/ocr.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ def convert_to_base64(images: list[Image.Image]) -> list[str]:
encoded_images = []

for img in images:
if img.mode in ("RGBA", "P"):
img = img.convert("RGB")

with io.BytesIO() as buffer:
img.save(buffer, format="JPEG")
img_byte_arr = buffer.getvalue()
Expand Down

0 comments on commit dd42083

Please sign in to comment.