Error when trying to convert jpeg 2000 file #11

Closed
opened 2021-04-25 19:57:32 +00:00 by josch · 0 comments
Owner

By josch on 2015-03-15T09:41:49.510Z

Created by: boxerab

FIrst off, thank you so much for this lovely app!

I am trying to conver a jpeg 2k file to pdf:

You can find the file here:

https://github.com/CodecCentral/openjpeg-data/tree/master/input/conformance

File name is:

zoo1.jp2

I get an error : broken data stream when reading image file

Thanks!
Aaron

PS I am using the latest github source

Imported comments:

By josch on 2014-04-05 18:56:55 UTC

I actually get a different error:

Traceback (most recent call last):
  File "src/img2pdf.py", line 340, in <module>
    main()
  File "src/img2pdf.py", line 337, in main
    args.subject, args.keywords, args.colorspace, args.verbose))
  File "src/img2pdf.py", line 220, in convert
    width, height, ics = parsejp2(rawdata)
  File "/home/josch/img2pdf/src/jp2.py", line 75, in parsejp2
    width, height, colorspace = parse_jp2h(boxContents)
  File "/home/josch/img2pdf/src/jp2.py", line 64, in parse_jp2h
    colorspace = parse_colr(boxContents)
  File "/home/josch/img2pdf/src/jp2.py", line 52, in parse_colr
    raise Exception("only sRGB and greyscale color space is supported, got %d"%enumCS)
Exception: only sRGB and greyscale color space is supported, got 18

Color 18 is sYCC. I would not know how to handle images in that color space.

By boxerab on 2014-04-05 19:08:58 UTC

Thanks for checking. It is strange that we get different errors. I am using python 2.7 on windows, if that makes a difference.

By josch on 2014-04-05 19:12:22 UTC

I'm using python 2.7 and python-pil 2.3.0 on Debian testing. I'm more interested in what part exactly throws your error message " broken data stream when reading image file"

By boxerab on 2014-04-05 21:13:24 UTC

OK, how can I test this for you?

By josch on 2014-04-05 21:16:55 UTC

Well, usually when you run a Python program and it exits because of an error, it gives you a traceback looking like the one I pasted above. Apparently no source package in all of Debian contains the string "broken data stream when reading image file" so I'm at a loss where it could come from.

By boxerab on 2014-04-05 22:42:58 UTC

ahhh, it is a PIL error:

Microsoft Windows [VC:\src\openjpeg-data\input\conformance>img2pdf zoo1.jp2 -o temp.pdf
Traceback (most recent call last):
File "c:\Python27\Scripts\img2pdf-script.py", line 9, in
load_entry_point('img2pdf==0.1.0', 'console_scripts', 'img2pdf')()
File "C:\Python27\lib\site-packages\img2pdf.py", line 337, in main
args.subject, args.keywords, args.colorspace, args.verbose))
File "C:\Python27\lib\site-packages\img2pdf.py", line 269, in convert
imgdata = zlib.compress(imgdata.tostring())
File "C:\Python27\lib\site-packages\PIL\Image.py", line 582, in tostring
return self.tobytes(*args, **kw)
File "C:\Python27\lib\site-packages\PIL\Image.py", line 556, in tobytes
self.load()
File "C:\Python27\lib\site-packages\PIL\Jpeg2KImagePlugin.py", line 181, in lo
ad
ImageFile.ImageFile.load(self)
File "C:\Python27\lib\site-packages\PIL\ImageFile.py", line 234, in load
raise_ioerror(e)
File "C:\Python27\lib\site-packages\PIL\ImageFile.py", line 56, in raise_ioerr
or
raise IOError(message + " when reading image file")
IOError: broken data stream when reading image file

By boxerab on 2014-04-05 22:54:07 UTC

yeah, I found that this is an error with the version of PIL that I have. So, don't worry about it.
I shouldn't be using windows anyways :)

*By josch on 2015-03-15T09:41:49.510Z* *Created by: boxerab* FIrst off, thank you so much for this lovely app! I am trying to conver a jpeg 2k file to pdf: You can find the file here: https://github.com/CodecCentral/openjpeg-data/tree/master/input/conformance File name is: zoo1.jp2 I get an error : broken data stream when reading image file Thanks! Aaron PS I am using the latest github source **Imported comments:** *By josch on 2014-04-05 18:56:55 UTC* I actually get a different error: Traceback (most recent call last): File "src/img2pdf.py", line 340, in <module> main() File "src/img2pdf.py", line 337, in main args.subject, args.keywords, args.colorspace, args.verbose)) File "src/img2pdf.py", line 220, in convert width, height, ics = parsejp2(rawdata) File "/home/josch/img2pdf/src/jp2.py", line 75, in parsejp2 width, height, colorspace = parse_jp2h(boxContents) File "/home/josch/img2pdf/src/jp2.py", line 64, in parse_jp2h colorspace = parse_colr(boxContents) File "/home/josch/img2pdf/src/jp2.py", line 52, in parse_colr raise Exception("only sRGB and greyscale color space is supported, got %d"%enumCS) Exception: only sRGB and greyscale color space is supported, got 18 Color 18 is sYCC. I would not know how to handle images in that color space. *By boxerab on 2014-04-05 19:08:58 UTC* Thanks for checking. It is strange that we get different errors. I am using python 2.7 on windows, if that makes a difference. *By josch on 2014-04-05 19:12:22 UTC* I'm using python 2.7 and python-pil 2.3.0 on Debian testing. I'm more interested in what part exactly throws your error message " broken data stream when reading image file" *By boxerab on 2014-04-05 21:13:24 UTC* OK, how can I test this for you? *By josch on 2014-04-05 21:16:55 UTC* Well, usually when you run a Python program and it exits because of an error, it gives you a traceback looking like the one I pasted above. Apparently no source package in all of Debian contains the string "broken data stream when reading image file" so I'm at a loss where it could come from. *By boxerab on 2014-04-05 22:42:58 UTC* ahhh, it is a PIL error: Microsoft Windows [VC:\src\openjpeg-data\input\conformance>img2pdf zoo1.jp2 -o temp.pdf Traceback (most recent call last): File "c:\Python27\Scripts\img2pdf-script.py", line 9, in <module> load_entry_point('img2pdf==0.1.0', 'console_scripts', 'img2pdf')() File "C:\Python27\lib\site-packages\img2pdf.py", line 337, in main args.subject, args.keywords, args.colorspace, args.verbose)) File "C:\Python27\lib\site-packages\img2pdf.py", line 269, in convert imgdata = zlib.compress(imgdata.tostring()) File "C:\Python27\lib\site-packages\PIL\Image.py", line 582, in tostring return self.tobytes(*args, **kw) File "C:\Python27\lib\site-packages\PIL\Image.py", line 556, in tobytes self.load() File "C:\Python27\lib\site-packages\PIL\Jpeg2KImagePlugin.py", line 181, in lo ad ImageFile.ImageFile.load(self) File "C:\Python27\lib\site-packages\PIL\ImageFile.py", line 234, in load raise_ioerror(e) File "C:\Python27\lib\site-packages\PIL\ImageFile.py", line 56, in raise_ioerr or raise IOError(message + " when reading image file") IOError: broken data stream when reading image file *By boxerab on 2014-04-05 22:54:07 UTC* yeah, I found that this is an error with the version of PIL that I have. So, don't worry about it. I shouldn't be using windows anyways :)
josch closed this issue 2021-04-25 19:57:32 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
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#11
No description provided.