Working with Images

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 →

Use image areas to inspect page coordinates, image types, and to save embedded resources in the desired format.

Save images to streams

from groupdocs.parser import Parser

with Parser("brochure.pdf") as parser:
    images = parser.get_images()
    if images is None:
        print("Image extraction isn't supported for this format.")
    elif not images:
        print("No images found")
    else:
        for image_area in images:
            # The image stream is a .NET MemoryStream; to_array() returns its bytes
            with image_area.get_image_stream() as stream:
                data = stream.to_array()
                print(f"Read {len(data)} bytes from page {image_area.page.index + 1}")

The following sample file is used in this example: brochure.pdf

Read 16247 bytes from page 1
Read 125180 bytes from page 1
Read 69728 bytes from page 1
Read 94989 bytes from page 1
Read 96241 bytes from page 1
Read 163435 bytes from page 2
Read 96241 bytes from page 2

Download full output

Tips

  • PageImageArea exposes rectangle, page, and file_type so you can filter by size or format.
  • Use save(path) for convenience or get_image_stream() when you need to process bytes in memory.
  • For large documents, stop iterating once you have saved the images you need to minimize memory usage.