react-pdf icon indicating copy to clipboard operation
react-pdf copied to clipboard

Image component doesn't handle EXIF image metadata so rotates some images

Open SamWoolerton opened this issue 3 years ago • 7 comments

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.

SamWoolerton avatar Jun 30 '21 01:06 SamWoolerton

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.

taipignas avatar Sep 27 '21 08:09 taipignas

@SamWoolerton @taipignas can you provide minimal reproduction with photo for this bug? I try to fix it

jeetiss avatar Oct 16 '21 08:10 jeetiss

I did it

jeetiss avatar Oct 16 '21 13:10 jeetiss

Hello, same issue here. Are you working on a fix @jeetiss ?

tomherbin avatar Oct 29 '21 19:10 tomherbin

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.

jeetiss avatar Oct 30 '21 08:10 jeetiss

Any updates for this?

phamyqb avatar Sep 22 '22 04:09 phamyqb

@SamWoolerton I think rotating later after the calculation might have this issue https://github.com/diegomura/react-pdf/issues/2014

ghost avatar Sep 22 '22 06:09 ghost