Skip to content

Commit ed8a5d1

Browse files
committed
Ok fixed rotation stuff finally
1 parent e0158df commit ed8a5d1

File tree

2 files changed

+260
-383
lines changed

2 files changed

+260
-383
lines changed

olmocr/pipeline.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,14 @@ async def build_page_query(local_pdf_path: str, page: int, target_longest_image_
114114
if image_rotation != 0:
115115
image_bytes = base64.b64decode(image_base64)
116116
with Image.open(BytesIO(image_bytes)) as img:
117-
rotated_img = img.rotate(-image_rotation, expand=True)
117+
if image_rotation == 90:
118+
tranpose = Image.Transpose.ROTATE_90
119+
elif image_rotation == 180:
120+
tranpose = Image.Transpose.ROTATE_180
121+
else:
122+
tranpose = Image.Transpose.ROTATE_270
123+
124+
rotated_img = img.transpose(tranpose)
118125

119126
# Save the rotated image to a bytes buffer
120127
buffered = BytesIO()

0 commit comments

Comments
 (0)