Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Work around Chrome bug with JPEG rotation information being lost after image is cloned #35

Closed
robertknight opened this issue Jun 4, 2022 · 0 comments · Fixed by #36
Closed

Comments

@robertknight
Copy link
Owner

This project needs to work around an issue where the EXIF rotation information from the input image in Chrome is lost when the ImageBitmap is transferred to a background thread by OCRClient for processing. See https://bugs.chromium.org/p/chromium/issues/detail?id=1332947.

robertknight added a commit that referenced this issue Jun 4, 2022
Chrome has a bug where image orientation metadata in JPEG images is lost
when an ImageBitmap is cloned via a structured clone [1]. Therefore we have
to do ImageBitmap => ImageData conversion on the main thread to ensure
that the OCR engine receives decoded image data which respects the image
orientation.

Prior to this fix the rendered image orientation and the OCR output did
not match up in Chrome if the input image was rotated.

Since neither Firefox nor Safari support OffscreenCanvas, this means
that all browsers are now doing ImageBitmap => ImageData conversion on
the main thread.

Fixes #35

[1] https://bugs.chromium.org/p/chromium/issues/detail?id=1332947
robertknight added a commit that referenced this issue Jun 4, 2022
Chrome has a bug where image orientation metadata in JPEG images is lost
when an ImageBitmap is cloned via a structured clone [1]. Therefore we have
to do ImageBitmap => ImageData conversion on the main thread to ensure
that the OCR engine receives decoded image data which respects the image
orientation.

Prior to this fix the rendered image orientation and the OCR output did
not match up in Chrome if the input image was rotated.

Since neither Firefox nor Safari support OffscreenCanvas, this means
that all browsers are now doing ImageBitmap => ImageData conversion on
the main thread.

Fixes #35

[1] https://bugs.chromium.org/p/chromium/issues/detail?id=1332947
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant