Extract Images from Documents

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

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.

Close
Loading

Analyzing your prompt, please hold on...

An error occurred while retrieving the results. Please refresh the page and try again.