Working with slide backgrounds

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.Watermark MCP server lets your agent work with files on your machine; they are never uploaded. It needs the .NET 10 SDK or Docker.

claude mcp add groupdocs-watermark -- dnx GroupDocs.Watermark.Mcp --yes
Folders, licensing and more →

Watermarker.get_content() returns a PresentationContent whose slides each expose an image_fill_format with a background_image, tile_as_texture, and transparency. The background image is None when the slide has no image fill.

Extract information about slide backgrounds

from groupdocs.watermark import Watermarker
from groupdocs.watermark.options.presentation import PresentationLoadOptions

def extract_slide_backgrounds():
    with Watermarker("./presentation.pptx", PresentationLoadOptions()) as watermarker:
        content = watermarker.get_content()
        for i, slide in enumerate(content.slides):
            background = slide.image_fill_format.background_image
            if background is not None:
                print(f"Slide {i}: background {background.width}x{background.height}")
            else:
                print(f"Slide {i}: no background image")

if __name__ == "__main__":
    extract_slide_backgrounds()

presentation.pptx is the sample file used in this example. Click here to download it.

Slide 0: background 1600x1000
Slide 1: no background image
Slide 2: background 640x400
Slide 3: no background image
Slide 4: no background image

Download full output

Remove a slide background

Set the background_image to None:

from groupdocs.watermark import Watermarker
from groupdocs.watermark.options.presentation import PresentationLoadOptions

def remove_slide_background():
    with Watermarker("./presentation.pptx", PresentationLoadOptions()) as watermarker:
        content = watermarker.get_content()
        content.slides[0].image_fill_format.background_image = None
        watermarker.save("./output.pptx")

if __name__ == "__main__":
    remove_slide_background()

presentation.pptx is the sample file used in this example. Click here to download it.

Binary file (PPTX, 137 KB)

Download full output

Watermark existing slide backgrounds

from groupdocs.watermark import Watermarker
from groupdocs.watermark.watermarks import TextWatermark, Font, Color
from groupdocs.watermark.options.presentation import PresentationLoadOptions

def watermark_slide_backgrounds():
    with Watermarker("./presentation.pptx", PresentationLoadOptions()) as watermarker:
        watermark = TextWatermark("CONFIDENTIAL", Font("Arial", 19.0))
        watermark.foreground_color = Color.red
        content = watermarker.get_content()
        for slide in content.slides:
            if slide.image_fill_format.background_image is not None:
                slide.image_fill_format.background_image.add(watermark)
        watermarker.save("./output.pptx")

if __name__ == "__main__":
    watermark_slide_backgrounds()

presentation.pptx is the sample file used in this example. Click here to download it.

Binary file (PPTX, 307 KB)

Download full output

You can also tune image_fill_format.transparency (0.0–1.0) and image_fill_format.tile_as_texture when setting a background image. The same image_fill_format is available on chart objects.