KeyError: 262 #129

Closed
opened 2 years ago by alatricta · 8 comments

Good afternoon. Please help: KeyError 262 errors occur during batch processing of files.

The 'АЦБР.466453.161-02.03И1.tif' file is being processed...Traceback (most recent call last):
File "D:\1234567\tiff2pdf.py", line 89, in <module>
main()
File "D:\1234567\tiff2pdf.py", line 75, in main
fuck = tiff2pdf()
File "D:\1234567\tiff2pdf.py", line 32, in tiff2pdf
converted_pdf = img2pdf.convert(input_file)
File "C:\Users\____\AppData\Roaming\Python\Python38\site-packages\img2pdf.py", line 2263, in convert
) in read_images(
File "C:\Users\____\AppData\Roaming\Python\Python38\site-packages\img2pdf.py", line 1665, in read_images
photo = imgdata.tag_v2[TiffImagePlugin.PHOTOMETRIC_INTERPRETATION]
File "C:\Users\____\AppData\Roaming\Python\Python38\site-packages\PIL\TiffImagePlugin.py", line 541, in __getitem__
data = self._tagdata[tag]
KeyError: 262
Good afternoon. Please help: KeyError 262 errors occur during batch processing of files. ``` The 'АЦБР.466453.161-02.03И1.tif' file is being processed...Traceback (most recent call last): File "D:\1234567\tiff2pdf.py", line 89, in <module> main() File "D:\1234567\tiff2pdf.py", line 75, in main fuck = tiff2pdf() File "D:\1234567\tiff2pdf.py", line 32, in tiff2pdf converted_pdf = img2pdf.convert(input_file) File "C:\Users\____\AppData\Roaming\Python\Python38\site-packages\img2pdf.py", line 2263, in convert ) in read_images( File "C:\Users\____\AppData\Roaming\Python\Python38\site-packages\img2pdf.py", line 1665, in read_images photo = imgdata.tag_v2[TiffImagePlugin.PHOTOMETRIC_INTERPRETATION] File "C:\Users\____\AppData\Roaming\Python\Python38\site-packages\PIL\TiffImagePlugin.py", line 541, in __getitem__ data = self._tagdata[tag] KeyError: 262 ```
alatricta closed this issue 2 years ago
alatricta reopened this issue 2 years ago
josch commented 2 years ago
Owner

The error doesn't come from img2pdf but from PIL/TiffImagePlugin.py. It seems that your tif file is missing the PHOTOMETRIC_INTERPRETATION tag. Can you post the file that you are having problems with?

The error doesn't come from img2pdf but from PIL/TiffImagePlugin.py. It seems that your tif file is missing the PHOTOMETRIC_INTERPRETATION tag. Can you post the file that you are having problems with?
Poster

Here on the site, I couldn't add it, I threw it on Google Drive

https://drive.google.com/file/d/1SbsQ1ex-GdF9zkbo0bhpNPEBGCUrn_pL/view?usp=drivesdk

Here on the site, I couldn't add it, I threw it on Google Drive https://drive.google.com/file/d/1SbsQ1ex-GdF9zkbo0bhpNPEBGCUrn_pL/view?usp=drivesdk
josch commented 2 years ago
Owner

I don't have a Google account so I cannot retrieve the file.

You can attach it to a post by first putting it into a zip archive.

I don't have a Google account so I cannot retrieve the file. You can attach it to a post by first putting it into a zip archive.
Poster

Ok

Ok
780 KiB
josch commented 2 years ago
Owner

That's just a corrupt image file. Even imagemagick says:

identify-im6.q16: improper image header `ðÉðªðæðá.466453.161-02.03ð1.tif' @ error/tiff.c/ReadTIFFImage/1327.

So this is not an img2pdf bug. Your input is broken.

That's just a corrupt image file. Even imagemagick says: identify-im6.q16: improper image header `ðÉðªðæðá.466453.161-02.03ð1.tif' @ error/tiff.c/ReadTIFFImage/1327. So this is not an img2pdf bug. Your input is broken.
Poster

It's a pity, because there are a lot of such files in the bundle. :-(
These files are opened and translated to pdf, for example FineReader.
Can you tell me how you can solve the problem?

It's a pity, because there are a lot of such files in the bundle. :-( These files are opened and translated to pdf, for example FineReader. Can you tell me how you can solve the problem?
josch commented 2 years ago
Owner

First, I'd send a bug report to the maintainers of the software that produced these files.

Second, I'd try finding some software that can open those files and convert them to another lossless raster graphics format like png.

First, I'd send a bug report to the maintainers of the software that produced these files. Second, I'd try finding some software that can open those files and convert them to another lossless raster graphics format like png.
Poster

Okay, thanks a lot.

Okay, thanks a lot.
alatricta closed this issue 2 years ago
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#129
Loading…
There is no content yet.