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

Images are set with invalid orientation EXIF tag #248

Open
xeals opened this issue Jan 9, 2021 · 5 comments
Open

Images are set with invalid orientation EXIF tag #248

xeals opened this issue Jan 9, 2021 · 5 comments

Comments

@xeals
Copy link

xeals commented Jan 9, 2021

Captured images are set with an Orientation EXIF flag of 0. This is an invalid value and will cause issues in applications that do not handle it.

Steps to reproduce

Take a photo and check its Orientation EXIF tag.

Expected behaviour

Orientation flag is set to a valid value. As photos are not rotated regardless of phone orientation, it should probably always be the default portrait (1).

Actual behaviour

Orientation flag is set to 0.

@sphh
Copy link

sphh commented Feb 12, 2021

I just ran into the same problem: I scan the notes with OpenNoteScanner, transfer the .jpg files to my computer and use img2pdf to convert them to pdfs. img2pdf complains with

ERROR:root:error: Invalid rotation (0)

I think, @xeals suggestion to set the Orientation EXIF tag to 1 is a good one.

@cdpb
Copy link

cdpb commented Nov 17, 2021

I think, @xeals suggestion to set the Orientation EXIF tag to 1 is a good one.

exiv2 -M"set Exif.Image.Orientation 1" *.jpg

... for reference

@kimek
Copy link

kimek commented Dec 6, 2022

Don't set orientation in exif to 1 as this will flip your image after using img2pdf
In man img2pdf
-r ROT, --rotation ROT, --orientation ROT Specifies how input images should be rotated. ROT can be one of auto, none, ifvalid, 0, 90, 180 and 270. The default value is auto and indicates that input images are rotated according to their EXIF Orientation tag. The values none and 0 ignore the EXIF Orientation values of the input images. The value ifvalid acts like auto but ignores invalid EXIF rotation values and only issues a warning instead of throwing an error. This is useful because many devices like Android phones, Canon cameras or scanners emit an invalid Orientation tag value of zero. The values 90, 180 and 270 perform a clockwise rotation of the image.
Therefore use flag --rotation=none if cli or python example: (fearis nickname )
https://stackoverflow.com/questions/60384205/invalid-rotation-when-converting-jpg-to-pdf-with-python/74707233#74707233

More on oficial page: https://github.com/josch/img2pdf#bugs

Remember that rotation argument is quiet new, is in 4.02 version of img2pdf (as I remember), newest is 4.04

@sphh
Copy link

sphh commented Dec 6, 2022

@kimek: So it would be

exiv2 -M"del Exif.Image.Orientation" *.jpg

before running img2pdf?

@allgood: Do you think, it is possible to remove the Orientation tag from the scanned images automatically?

@kimek
Copy link

kimek commented Dec 6, 2022

@sphh Yes, that would work to. I've just tested that with img2pdf ver 3 which doesnt support rotation. In this case deleting orientation would be easier. Good point.
However... ideally you should avoid situation where "cause of 3rd party program you need to change your files".
Just be aware about deleting exif data, as there is no point of return

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

No branches or pull requests

4 participants