Extract Images from Documents

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Parser MCP server lets your agent work with files on your machine; they are never uploaded. It runs in Docker: replace /path/to/documents with the folder it may use.

claude mcp add groupdocs-parser -- docker run --rm -i -v /path/to/documents:/data ghcr.io/groupdocs-parser/parser-net-mcp:latest
Folders, licensing and more →

GroupDocs.Parser can list and export images from supported documents (PDF, Office, emails, eBooks, and more).

Extract images

from groupdocs.parser import Parser

with Parser("./slides.pptx") as parser:
    images = parser.get_images()
    if images is None:
        print("Image extraction isn't supported for this format.")
    else:
        print(f"Found {len(images)} images")
        for index, image_area in enumerate(images, start=1):
            print(f"Page: {image_area.page.index + 1}, Type: {image_area.file_type.file_format}")
            # Save each image (the extension includes the dot, e.g. ".png")
            output_path = f"image-{index}{image_area.file_type.extension}"
            image_area.save(output_path)

The following sample file is used in this example: slides.pptx

image-1.png (4 KB)
image-2.jpeg (136 KB)
image-3.jpeg (75 KB)
image-4.jpeg (105 KB)

Download full output

Steps

  1. Create Parser for the source file.
  2. Call get_images() to obtain PageImageArea items.
  3. Inspect page, rectangle, file_type, and save streams with save() or get_image_stream().

For coordinates-based processing and format conversion, see the advanced images guide; the same workflow applies in Python.