NameError: global name 'im' is not defined #61
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?
By allan on 2019-03-28T08:44:18.885Z
I'm using the latest version from pip , I will try to see if I can get the original image
By josch on 2019-03-28T08:57:09.240Z
Status changed to closed by commit
07903e9ef1
By josch on 2019-03-28T08:57:23.882Z
No need, this issue was simple enough. Thanks! :)
By allan on 2019-03-28T08:58:40.009Z
if I replace by imgdata then i got
By allan on 2019-03-28T08:59:08.271Z
damn that was fast :)
By allan on 2019-03-28T09:00:01.434Z
ok if i apply the patch locally, I now got
By allan on 2019-03-28T09:00:58.143Z
(if you could tag a bufix version that would be awesome )
By josch on 2019-03-28T09:02:13.748Z
Yes, that is the problem. "0" is not a valid exif orientation. Which program produced your image?
By allan on 2019-03-28T09:04:21.307Z
I will try to get this information, but basically we have a webservice that allow people to upload some documents as jpg/png, and we convert them to pdf , so we're not really under control of the software.
By josch on 2019-03-28T09:07:13.768Z
How about you add a preprocessing step then which removes any invalid exif orientation tags?
If you get arbitrary input you need such a sanitation step anyways. Not the least because img2pdf will refuse to convert images with an alpha channel.
By allan on 2019-03-28T09:11:39.284Z
yes I already have some code for the alpha channel :)
so here for exif, you would advice me to default on one exif orientation if no good value are found?
Can we make that by you throwing a "InvalidExiftOrientation" , so that user code know when to run this kind of "cleaning code" ?
(so that not to have to duplicate your checking code)
By josch on 2019-03-28T09:14:29.982Z
Are you using img2pdf as an application or as a library?
Which exif orientation you pick is totally up to you and your use case. :) I guess if the exif orientation value is invalid, I would just delete the whole tag altogether.
Yes, I could add an InvalidExiftOrientation exception. There is no such exception for the alpha channel error yet. Would you appreciate one there as well?
By allan on 2019-03-28T09:17:02.010Z
as a library
for the exif orientation, yes I didn't know if removing it all together would have please img2pdf ^^
yes for alphachannelerror, any kind of specific exception for which as a user of your library I can try to "do some stuff to prevent the exception from re-happening" is good to have as a specific exception
By josch on 2019-03-28T09:29:02.188Z
Okay, fixed in git master. But before doing a new release I was planning to fix issue #59.
By Shaib8qu on 2020-01-22T11:49:13.131Z
I don't know whether it is the same thing. I use
img2pdf
as an app, not as a library. I gotwhen converting a jpg file. After some tries, I observe that it appears when I convert photos captured by
OpenCamera
with HDR.I am not sure whether it is the same issue as this one, but after googling the keyword
img2pdf im not defined
, I find this issue.(Now I temporarily use
tesseract
to do the lossless conversion with success)By josch on 2020-01-22T19:55:55.649Z
@uM8Ma8fa To say anything to your issue I need more information. Which version of img2pdf are you running? And can you supply me with an input image?
By Shaib8qu on 2020-01-22T21:46:02.544Z
By josch on 2020-01-22T21:57:35.150Z
You were correct. The issue you see is the same that @allan saw. Essentially your jpeg contains an invalid exif rotation value, namly "0". Only values 1 to 8 are valid. You should file a bug with whichever software created that image.