I'm trying to convert a jpg to pdf with img2pdf.
It works with most jpg's but not all.
Here is my script:
import img2pdf
import PIL.Image
import os
image = PIL.Image.open("Lidl.jpg")
pdf_bytes = img2pdf.convert(image.filename)
file = open(pdf_path, "wb")
file.write("file.pdf")
image.close()
file.close()
Here is the error I get:
Traceback (most recent call last):
File "test.py", line 8, in <module>
pdf_bytes = img2pdf.convert(image.filename)
File "/home/ksb/Dropbox/Python/imap/venv/lib/python3.6/site-packages/img2pdf.py", line 1829, in convert
) in read_images(rawdata, kwargs["colorspace"], kwargs["first_frame_only"]):
File "/home/ksb/Dropbox/Python/imap/venv/lib/python3.6/site-packages/img2pdf.py", line 1191, in read_images
imgdata, imgformat, default_dpi, colorspace, rawdata
File "/home/ksb/Dropbox/Python/imap/venv/lib/python3.6/site-packages/img2pdf.py", line 1030, in get_imgmetadata
'Image "%s": invalid rotation (%d)' % (im.name, value)
NameError: name 'im' is not defined
If I look into the image meta data it says:
Unknown rotation value 0
ColorSpace=sRGB
Is is possible to set the rotation value?
Any hints are very much appreciated.
BR Kresten