Applies EXIF orientation rotation FIRST so phone-sideways receipts
(which carry an EXIF orientation tag instead of being physically
rotated) are uprighted before any pixel-aware step. Skipping this
leaves sideways text in the OCR pipeline and tanks tesseract.js
accuracy on Hebrew.
Width is computed from the POST-rotation pixel dimensions: EXIF
orientations 5/6/7/8 swap width and height during .rotate(), so
a phone-portrait photo (EXIF=6, raw 1800x900) presents itself as
900x1800 to the OCR pipeline and must be upscaled accordingly.
Checking pre-rotation metadata.width would skip the upscale and
silently degrade OCR quality on the dominant phone-photo case.
Preprocesses an image buffer for receipt OCR.
Applies EXIF orientation rotation FIRST so phone-sideways receipts (which carry an EXIF orientation tag instead of being physically rotated) are uprighted before any pixel-aware step. Skipping this leaves sideways text in the OCR pipeline and tanks tesseract.js accuracy on Hebrew.
Width is computed from the POST-rotation pixel dimensions: EXIF orientations 5/6/7/8 swap width and height during
.rotate(), so a phone-portrait photo (EXIF=6, raw 1800x900) presents itself as 900x1800 to the OCR pipeline and must be upscaled accordingly. Checking pre-rotationmetadata.widthwould skip the upscale and silently degrade OCR quality on the dominant phone-photo case.