Main Content

Create and Format Pictures

Create a Picture

This example shows how to create a picture for a presentation by using the mlreportgen.ppt.Picture constructor.

import mlreportgen.ppt.*
ppt = Presentation("slides");
pictureSlide = add(ppt,"Blank");

Specify the path to a picture file.

plane = Picture("b747.jpg");
plane.Width = "5in";
plane.Height = "2in";

Add the slide to the presentation.

add(pictureSlide,plane);
close(ppt);

Format a Picture

When you create a Picture object, you can specify the location, width, and height. The specified formatting applies when you add a picture to a slide or replace a Picture object. When you replace a PicturePlaceholder object with a Picture object, PowerPoint® adjusts the replacement picture to fit the location and dimensions of the placeholder.

You can specify these format properties for a Picture object.

Picture Object Formatting Format ObjectFormat Property

Upper-left x-coordinate of picture

n/a

X

Upper-left y-coordinate of picture

n/a

Y

Picture width

n/a

Width

Picture height

n/a

Height

Supported Image Formats

The PPT API supports the image formats in this table.

Image FormatFile Extension
Windows® Enhanced Metafile.emf
Encapsulated PostScript®.eps
Graphics Interchange Format .gif
Joint Photographic Experts Group.jpeg, .jpg
Portable Network Graphics.png
Scalable Vector Graphics.svg
Tagged Image File Format.tif, .tiff

Note

To ensure that the image formats used in your generated presentation are supported by the PowerPoint version that you are using, see File formats that are supported in PowerPoint on the Microsoft® website.

See Also

Classes

Topics