react-pdf
react-pdf copied to clipboard
Image component doesn't handle EXIF image metadata so rotates some images
Describe the bug
Image
component doesn't handle EXIF image metadata so displays some images rotated.
To Reproduce Display an image taken in portrait orientation (without stripping the metadata first).
Expected behavior The image should display in the original portrait orientation. It instead displays rotated.
Desktop (please complete the following information):
- OS: Windows
- Browser: Chrome and Brave (basically Chrome)
- React-pdf version: 2.0.12
I've worked around this by using exif.js to detect the orientation and then apply CSS transforms (rotate and scale) to get the image back to how it should be; would be nice for that to all be handled by the Image
component itself though.
I also have this issue with photos taken with iphone. Photos have metadata "OrientationRotate 90 CW" and pdf renderer renders them without rotation, while html rotates them to intended rotation.
@SamWoolerton @taipignas can you provide minimal reproduction with photo for this bug? I try to fix it
Hello, same issue here. Are you working on a fix @jeetiss ?
I wrote the exif parser for jpeg
and faced with code duplication problem, project use two copy of image classes:
- https://github.com/diegomura/react-pdf/blob/master/packages/image/src/jpeg.js
- https://github.com/diegomura/react-pdf/blob/master/packages/pdfkit/src/image/jpeg.js
This affects performance and adds headache for right exif implementation, so I pause work on this task. You can help, if you want.
Any updates for this?
@SamWoolerton I think rotating later after the calculation might have this issue https://github.com/diegomura/react-pdf/issues/2014