Skip to content
Discussion options

You must be logged in to vote

Thanks for using PyMuPDF to start with.
The easiest way to achieve your goal surprisingly (maybe) is to not extract the image, but to make a "photo" from the area where the image is visible - and save this as an image.
Step 1: Identify the image
Step 2: Compute the area where displayed by the page
Step 3: Make a Pixmap from that area. This will contain everything visible: the image and possible other stuff.
Step 4: Save the Pixmap as an image file.

Of course the result quality will depend on the DPI you choose for the pixmap.
Here is a snippet. I am assuming you have the xref of the image of interest:

bbox = page.get_image_rects(xref)[0]  # delivers list, because one image maybe displayed…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@kay9911
Comment options

Answer selected by kay9911
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants