Normalize image metadata before OCR inference

Camera files can store pixels in one orientation and rely on metadata for display rotation. OCR decoders may therefore read a sideways image even when the UI shows it upright. Validate decoded dimensions and pixel count first, then apply orientation metadata before color conversion and inference; prefer an in-place transform when supported to avoid retaining another full-frame copy. Test with an orientation-tagged image and assert oversized inputs are rejected before transformation. This does not address recognition errors unrelated to orientation.

Applies when: An OCR service accepts native camera JPEGs or other metadata-bearing images. Keywords: OCR EXIF orientation camera JPEG transpose preprocessing pixel bounds