# Image extraction issues

**URL:** <https://forum.mupdf.com/t/image-extraction-issues/151>\
**Category:** PyMuPDF\
**Created:** [September 10, 2025, 11:09pm UTC](https://forum.mupdf.com/t/image-extraction-issues/151 "2025-09-10T23:09:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yixuan\_Liu](https://yyz2.discourse-cdn.com/flex004/user_avatar/forum.mupdf.com/yixuan_liu/32/4_2.png) [@Yixuan\_Liu](https://forum.mupdf.com/u/Yixuan_Liu)\
**Post date:** [September 10, 2025, 11:09pm UTC](https://forum.mupdf.com/t/image-extraction-issues/151/1 "2025-09-10T23:09:16Z")

</div>

Hi there,

I found some issues related with images.

For Page 1, I can get this image using get\_images(full=True). However, this is a cropped image. While I’m trying to redact it, it will redact the original image while I just want to redact the visualized part. So my question for this would be: Is there any way that I can get the bbox for the visualized part?

 ![IMG_5700](https://canada1.discourse-cdn.com/flex004/uploads/mupdf/original/1X/f05cc1d84b8d8798a3958b7f94a51b2b563250c4.jpeg)

For Page 2, these images cannot be extracted using get\_images(). I can get most of them (see redacted ones) using get\_drawings and select the “clip” type, but the issues are:

 ![IMG_5701](https://canada1.discourse-cdn.com/flex004/uploads/mupdf/original/1X/ea80a51f9102427562bd456fc3b805b9063a77cb.jpeg)

While using get\_drawings method, I will get a clip for the whole page as well. How can I justify if a clip is for an image, or for the whole page.

I still cannot extract the Reckon image.

The SABIO one is extracted separately, is there anyway that I can extarct it as a whole?

Thx!

[test 1.pdf](https://forum.mupdf.com/uploads/short-url/gBR3h9WGynz8HqDZIp56ZtLbUj.pdf) (230.9 KB)

---

<div class="post-metadata">

**Author:** ![Jamie\_Lemon](https://yyz2.discourse-cdn.com/flex004/user_avatar/forum.mupdf.com/jamie_lemon/32/5_2.png) [@Jamie\_Lemon](https://forum.mupdf.com/u/Jamie_Lemon)\
**Post date:** [September 11, 2025, 4:11pm UTC](https://forum.mupdf.com/t/image-extraction-issues/151/2 "2025-09-11T16:11:07Z")

</div>

I had a quick look at your first issue regarding what I think might be an image mask. Looking here: [Images - PyMuPDF documentation](https://pymupdf.readthedocs.io/en/latest/recipes-images.html#how-to-handle-image-masks) I tried this:

```python
import pymupdf

doc = pymupdf.open("test 1.pdf") # open a document

for page_index in range(len(doc)): # iterate over pdf pages
    page = doc[page_index] # get the page
    image_list = page.get_images()
    # print the number of images found on the page
    if image_list:
        print(f"Found {len(image_list)} images on page {page_index}")
    else:
        print("No images found on page", page_index)

    for image_index, img in enumerate(image_list, start=1):

        xref = img[0] # get the XREF of the image
        smask = img[1]
        print(xref)
        print(smask)

        if smask > 0:
            print("consider mask!")
            pix1 = pymupdf.Pixmap(doc.extract_image(xref)["image"]) # (1) pixmap of image w/o alpha
            mask = pymupdf.Pixmap(doc.extract_image(smask)["image"]) # (2) mask pixmap
            pix = pymupdf.Pixmap(pix1, mask) # (3) copy of pix1, image mask added
        else:
            pix = pymupdf.Pixmap(doc, xref) # create a Pixmap

        if pix.n - pix.alpha > 3: # CMYK: convert to RGB first
            pix = pymupdf.Pixmap(pymupdf.csRGB, pix)

        pix.save("_page_%s-image_%s.png" % (page_index, image_index))
        pix = None

```

But unfortunately it didn’t seem to work. It looked to me like a different image had the mask on page 1 and not the one I was expecting?
