I am trying to OCR a PDF file in Python that contains JBIG2 encoded images. Originally started with PyPDF, I recognized that the limitation here is PIL: https://github.com/py-pdf/pypdf/issues/1989 Using PyMuPDF I can extract the JBIG2 images. With a simple check I can verify that the images are in JBIG2 format: if image_bytes["ext"] == "jb2": # do stuff As I am using Tesseract for OCR, I cannot do anything with the image bytes here. Next try was to use PikePDF to convert the JBIG2 images to PNG. Unfortunately, PikePDF wasn't able to find any image encoded in JBIG2 (see sample PDF in the issue above). Next, I tried to do it manually with PikePDF: with pikepdf.open(pdf) as p_pdf: print(len(p_pdf.pages[0].images)) pike_pdf_stream = Stream(p_pdf, image_bytes["image"], Filter=["/JBIG2Decode"], Subtype="/Image") p_jbig2_image = PdfImage(pike_pdf_stream) jbig2_image.extract_to(fileprefix='image') That didn't work either (maybe I miss something here?). Basically, my question is how to perform OCR on PDFs that include JBIG2 images. Related issue: Extract images from PDF, how to handle JBIG2 encoded Preferably, I don't want to use any command line tools. Do you have any ideas how to solve it? Continue reading...