Error on converting to pdf on some jpg images #102
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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)
Your input image uses the exif rotation 0 which is an invalid rotation. What kind of image are you passing to img2pdf?
**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
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 #100lib should be capable of auto handle this. Enduser doesnot know whats in his image meta data
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?
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
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.