Skip to content

How to extract the image in JPXDecode #1204

Description

@thaihaquang

Dear authors,
I am trying your tool to extract images from PDF using the below code


for i in range(len(doc)):
    for img in doc.getPageImageList(i):
        print("Processing ", i)
        xref = img[0]
        print (img)
        pix = fitz.Pixmap(doc, xref)
        if pix.n < 5:       # this is GRAY or RGB
            pix.writePNG("./out/p%s-%s.png" % (i, xref))
        else:               # CMYK: convert to RGB first
            pix1 = fitz.Pixmap(fitz.csRGB, pix)
            pix1.writePNG("./out/p%s-%s.png" % (i, xref))
            pix1 = None
        pix = None

All files are extracted OK, except a PDF file.

Each image in that PDF are saved to 2 strange images
I found that the decode filter of the image is "JPXDecode"
Below is the information I got from doc.getPageImageList(i)
[(85, 0, 1262, 1769, 8, 'DeviceRGB', '', 'Bg', 'JPXDecode'), (87, 86, 631, 885, 8, 'DeviceRGB', '', 'CL', 'JPXDecode')]

Could you help me to explain the reason and guide me on how to fix this issue?
Thank you very much.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions