Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jbig2dec error #181

Closed
RichardScottOZ opened this issue Mar 16, 2021 · 11 comments
Closed

jbig2dec error #181

RichardScottOZ opened this issue Mar 16, 2021 · 11 comments
Labels

Comments

@RichardScottOZ
Copy link

RichardScottOZ commented Mar 16, 2021

Hi, I installed this from anaconda (using windows 10, so don't know if it works necessarily, anyone else?)

and got this after I put an Exception handler in to tell me more :

(desurvey) C:\Users\rscott\OneDrive - OZ Minerals\Exploration\Research\Python>python pdftestpike5.py
  0%|                                                                                  | 1/739 [00:00<06:57,  1.77it/s]got jbig2dec ok
error opening C:\Users\rscott\AppData\Local\Temp\tmpjgzipp79
Command '['jbig2dec', '-e', '-o', 'C:\\Users\\rscott\\AppData\\Local\\Temp\\tmp70ma71kl', 'C:\\Users\\rscott\\AppData\\Local\\Temp\\tmpjgzipp79']' returned non-zero exit status 1.
  0%|                                                                                  | 1/739 [00:00<07:48,  1.58it/s]
Traceback (most recent call last):
  File "pdftestpike5.py", line 88, in <module>
    out = image.extract_to(fileprefix=f"{fileout}-page{i:03}-img{j:03}")
  File "C:\Users\rscott\AppData\Local\Continuum\anaconda3\envs\desurvey\lib\site-packages\pikepdf\models\image.py", line 568, in extract_to
    extension = self._extract_to_stream(stream=bio)
  File "C:\Users\rscott\AppData\Local\Continuum\anaconda3\envs\desurvey\lib\site-packages\pikepdf\models\image.py", line 525, in _extract_to_stream
    raise UnsupportedImageTypeError(repr(self))
pikepdf.models.image.UnsupportedImageTypeError: <pikepdf.PdfImage image mode=1 size=3906x2530 at 0x1d4ed183d30>

hopefully will get to try it on linux later

@jbarlow83
Copy link
Member

You need to make sure that you have jbig2dec installed and that Windows can find it on one of the PATH environment variables. That means, type jbig2dec --version at the same command prompt you use to run Python, and you should get the version number for that problem, not "file not found" or whatever Windows says right now.

I don't know if Anaconda installs it for you, but probably not. It's an external binary, not Python.

@jbarlow83
Copy link
Member

On Linux you can usually do $packagemanager install jbig2dec

@RichardScottOZ
Copy link
Author

Yeah, there was an anaconda package for it, so I installed that - so not in the Path then perhaps, will check that out, thanks.

@RichardScottOZ
Copy link
Author

@RichardScottOZ
Copy link
Author

RichardScottOZ commented Mar 17, 2021

Ok, this environment finds it ok :-

(desurvey) C:\Users\rscott\OneDrive - OZ Minerals\Exploration\Research\Python>jbig2dec --version
jbig2dec 0.18

(desurvey) C:\Users\rscott\OneDrive - OZ Minerals\Exploration\Research\Python>python pdftestpike5.py
  0%|                                                                                  | 1/739 [00:00<07:14,  1.70it/s]got jbig2dec ok
error opening C:\Users\rscott\AppData\Local\Temp\tmppx9xwoox
Command '['jbig2dec', '-e', '-o', 'C:\\Users\\rscott\\AppData\\Local\\Temp\\tmpcyvh_m9o', 'C:\\Users\\rscott\\AppData\\Local\\Temp\\tmppx9xwoox']' returned non-zero exit status 1.
  0%|                                                                                  | 1/739 [00:00<08:16,  1.49it/s]
Traceback (most recent call last):
  File "pdftestpike5.py", line 88, in <module>
    out = image.extract_to(fileprefix=f"{fileout}-page{i:03}-img{j:03}")
  File "C:\Users\rscott\AppData\Local\Continuum\anaconda3\envs\desurvey\lib\site-packages\pikepdf\models\image.py", line 568, in extract_to
    extension = self._extract_to_stream(stream=bio)
  File "C:\Users\rscott\AppData\Local\Continuum\anaconda3\envs\desurvey\lib\site-packages\pikepdf\models\image.py", line 525, in _extract_to_stream
    raise UnsupportedImageTypeError(repr(self))
pikepdf.models.image.UnsupportedImageTypeError: <pikepdf.PdfImage image mode=1 size=3906x2530 at 0x1694afa0cf8>

(desurvey) C:\Users\rscott\OneDrive - OZ Minerals\Exploration\Research\Python>

@RichardScottOZ
Copy link
Author

so not a path problem at least

@RichardScottOZ
Copy link
Author

RichardScottOZ commented Mar 17, 2021

I did put a check in here when I was looking into it, and it does make it to here

def jbig2dec_available() -> bool:
    try:
        run(['jbig2dec', '--version'], stdout=DEVNULL, check=True)
        print("got jbig2dec ok")
    except (CalledProcessError, FileNotFoundError):
        return False
    else:
        return True

@RichardScottOZ
Copy link
Author

So default jbig2dec version on the ec2 machine I tried first with an apt install 0.13, which doesn't have a -e flag, so will try another

@RichardScottOZ
Copy link
Author

However, the anaconda library worked ok on ubuntu, so the above problem a windows problem most likely. What versions of jbig2dec do you expect it to work with?

@jbarlow83
Copy link
Member

0.15 would be the minimum, when -e was introduced.
ArtifexSoftware/jbig2dec@c0353a0
It won't work properly without that.

I haven't attempted to establish a minimum before. I'll treat this as a bug that we don't provide an appropriate error message if jbig2dec is missing or too old.

@RichardScottOZ
Copy link
Author

Thanks.
This is the conda version I used on ubuntu - jbig2dec=0.18=he06d7ca_0
Looks like the ubuntu 18.04 package list had jbig2dec 0.13 and 20.04 has 0.18 or thereabouts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants