Error on converting to pdf on some jpg images #102

Closed
opened 2021-06-01 16:06:18 +00:00 by rishabh3354 · 7 comments

img2pdf.ExifOrientationError: Invalid rotation (0)

Traceback (most recent call last):
File "/home/warlord/projects/JPG2PDF/src/jpg2pdf.py", line 488, in
window = MainWindow()
File "/home/warlord/projects/JPG2PDF/src/jpg2pdf.py", line 89, in init
f.write(img2pdf.convert(tt))
File "/home/warlord/projects/JPG2PDF/src/img2pdf.py", line 2130, in convert
kwargs["rotation"],
File "/home/warlord/projects/JPG2PDF/src/img2pdf.py", line 1412, in read_images
imgdata, imgformat, default_dpi, colorspace, rawdata, rot
File "/home/warlord/projects/JPG2PDF/src/img2pdf.py", line 1240, in get_imgmetadata
raise ExifOrientationError("Invalid rotation (%d)" % value)
img2pdf.ExifOrientationError: Invalid rotation (0)

img2pdf.ExifOrientationError: Invalid rotation (0) Traceback (most recent call last): File "/home/warlord/projects/JPG2PDF/src/jpg2pdf.py", line 488, in window = MainWindow() File "/home/warlord/projects/JPG2PDF/src/jpg2pdf.py", line 89, in init f.write(img2pdf.convert(tt)) File "/home/warlord/projects/JPG2PDF/src/img2pdf.py", line 2130, in convert kwargs["rotation"], File "/home/warlord/projects/JPG2PDF/src/img2pdf.py", line 1412, in read_images imgdata, imgformat, default_dpi, colorspace, rawdata, rot File "/home/warlord/projects/JPG2PDF/src/img2pdf.py", line 1240, in get_imgmetadata raise ExifOrientationError("Invalid rotation (%d)" % value) img2pdf.ExifOrientationError: Invalid rotation (0)
Owner

Your input image uses the exif rotation 0 which is an invalid rotation. What kind of image are you passing to img2pdf?

Your input image uses the exif rotation 0 which is an invalid rotation. What kind of image are you passing to img2pdf?
Author

**this is my code
**
tt= ['/home/warlord/Downloads/sample.jpg']
import img2pdf
with open("name.pdf", "wb") as f:
f.write(img2pdf.convert(tt))

**this is output
**
Traceback (most recent call last):
File "/home/warlord/projects/JPG2PDF/src/jpg2pdf.py", line 512, in
window = MainWindow()
File "/home/warlord/projects/JPG2PDF/src/jpg2pdf.py", line 113, in init
f.write(img2pdf.convert(tt))
File "/home/warlord/projects/jpg2pdf_env/lib/python3.6/site-packages/img2pdf.py", line 2102, in convert
) in read_images(rawdata, kwargs["colorspace"], kwargs["first_frame_only"]):
File "/home/warlord/projects/jpg2pdf_env/lib/python3.6/site-packages/img2pdf.py", line 1389, in read_images
imgdata, imgformat, default_dpi, colorspace, rawdata
File "/home/warlord/projects/jpg2pdf_env/lib/python3.6/site-packages/img2pdf.py", line 1227, in get_imgmetadata
raise ExifOrientationError("Invalid rotation (%d)" % value)
img2pdf.ExifOrientationError: Invalid rotation (0)

** file in attachment**

I am using python 3.6.13

**this is my code ** tt= ['/home/warlord/Downloads/sample.jpg'] import img2pdf with open("name.pdf", "wb") as f: f.write(img2pdf.convert(tt)) **this is output ** Traceback (most recent call last): File "/home/warlord/projects/JPG2PDF/src/jpg2pdf.py", line 512, in <module> window = MainWindow() File "/home/warlord/projects/JPG2PDF/src/jpg2pdf.py", line 113, in __init__ f.write(img2pdf.convert(tt)) File "/home/warlord/projects/jpg2pdf_env/lib/python3.6/site-packages/img2pdf.py", line 2102, in convert ) in read_images(rawdata, kwargs["colorspace"], kwargs["first_frame_only"]): File "/home/warlord/projects/jpg2pdf_env/lib/python3.6/site-packages/img2pdf.py", line 1389, in read_images imgdata, imgformat, default_dpi, colorspace, rawdata File "/home/warlord/projects/jpg2pdf_env/lib/python3.6/site-packages/img2pdf.py", line 1227, in get_imgmetadata raise ExifOrientationError("Invalid rotation (%d)" % value) img2pdf.ExifOrientationError: Invalid rotation (0) ** file in attachment** I am using python 3.6.13
Owner

According to the metadata, the photo was shot with a "Canon EOS 700D" camera -- is that correct? It seems that camera writes the invalid rotation value 0 in its metadata. In the next img2pdf version you can run img2pdf with --rotation=ifvalid which will allow conversion of images with faulty exif information. See #100

According to the metadata, the photo was shot with a "Canon EOS 700D" camera -- is that correct? It seems that camera writes the invalid rotation value 0 in its metadata. In the next img2pdf version you can run img2pdf with `--rotation=ifvalid` which will allow conversion of images with faulty exif information. See #100
Author

According to the metadata, the photo was shot with a "Canon EOS 700D" camera -- is that correct? It seems that camera writes the invalid rotation value 0 in its metadata. In the next img2pdf version you can run img2pdf with --rotation=ifvalid which will allow conversion of images with faulty exif information. See #100

lib should be capable of auto handle this. Enduser doesnot know whats in his image meta data

> According to the metadata, the photo was shot with a "Canon EOS 700D" camera -- is that correct? It seems that camera writes the invalid rotation value 0 in its metadata. In the next img2pdf version you can run img2pdf with `--rotation=ifvalid` which will allow conversion of images with faulty exif information. See #100 lib should be capable of auto handle this. Enduser doesnot know whats in his image meta data
Owner

Imagine you are writing a program that takes input files, operates on them and then writes some files as output. Now you are passing broken input files to that program. Should that program complain? I think it should. Do you prefer software that silently ignores errors?

Imagine you are writing a program that takes input files, operates on them and then writes some files as output. Now you are passing broken input files to that program. Should that program complain? I think it should. Do you prefer software that silently ignores errors?
Author

i made a Snap Application made using fpdf2, pikepdf, and PIL. i was first trying to use img2pdf but not impressed with this library.

check it out https://snapcraft.io/jpg2pdf

thanks

i made a Snap Application made using fpdf2, pikepdf, and PIL. i was first trying to use img2pdf but not impressed with this library. check it out https://snapcraft.io/jpg2pdf thanks
Owner

If you believe that this issue can be closed, please either close it, or tell me what else is missing before it can be closed.

If you believe that this issue can be closed, please either close it, or tell me what else is missing before it can be closed.
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: josch/img2pdf#102
No description provided.