I'm trying to convert some .jb2e images, which I extracted from a PDF, into a proper, common image file format like PNG or JPG. I tried using jbig2dec, but that told me

jbig2dec FATAL ERROR Not a JBIG2 file header 

What else can I try?

I'm using Devuan ASCII (~= Debian Stretch).


I ran into the same issue, and was able to get PNG versions by using pdfimages from the Poppler utils on the original PDF, with the -png flag (and not the -all flag), so that it outputs all the images in the PDF as PNGs.

This is because the -png flag is not the same as the -j and -jbig2 flags (all of these are selected by -all): -png sets the output format, which is the default for all images to be output as, converting if necessary. Converting is actually the default for pdfimages; with no format flags, it converts all images to PBM and PPM files. -j and -jbig2, on the other hand, specify not to convert images of those types, thus they are output in their original format. (Note that this means there's no option to convert images to JPEG in this program; only files stored as JPEGs are output as JPEG with the -j option.)

| improve this answer | |
  • Wouldn't that only work if the PDF was created with PNG rather than JB2E images originally? – einpoklum May 15 at 17:07
  • No, the -png and -tiff output options do conversions. The -j, -jp2, -jbig2, and -ccitt options request not to convert those file types and to output them as is. The -all option outputs some types verbatim, some as TIFF, the rest as PNG. (It was not clear to me either until I read it a lot of times.) – Dan Getz May 15 at 18:09
  • How inconsistent... :-( but thanks. – einpoklum May 15 at 22:05

If the .jb2e is a single page extracted from a pdf, use:

jbig2dec -t png -o output.png /dev/null input.jb2e

According to jbig2dec's manpage:

jbig2dec [options] global-stream page-stream

If a particular page references no global segment stream, /dev/null can be passed for the global-stream argument to request the embedded parser.

| improve this answer | |
  • Thanks, worked perfectly on my test file. Brings up a question for me: how is one to know that a file is a JBIG2 "segment stream" instead of a "single file"? (Just be aware that both types exist and try each way?) – Dan Getz Jun 9 at 15:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.