mlreportgen.ppt.Picture Class
R2026bNamespace: mlreportgen.ppt
Picture to include in presentation
Description
Use an object of the mlreportgen.ppt.Picture class to include a picture
in a presentation.
The mlreportgen.ppt.Picture class is a handle class.
Class Attributes
ConstructOnLoad | true |
HandleCompatible | true |
For information on class attributes, see Class Attributes.
Creation
Description
creates an empty pictureObj = mlreportgen.ppt.PicturePicture object.
creates a pictureObj = mlreportgen.ppt.Picture(picturePath)Picture object that contains the picture specified by
picturePath.
Note
Closing the mlreportgen.ppt.Presentation object copies the
contents of the specified picture file into the output presentation. Do not
delete or overwrite the picture file before the copying process completes. If
you create a picture file and the corresponding
mlreportgen.ppt.Picture object in a loop, use a unique file
name for the picture file in each loop iteration.
Input Arguments
Path and name of a picture file, specified as a character vector or string scalar. The PowerPoint (PPT) API supports the image formats in the table.
| Image Format | File 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 see which file formats your version of PowerPoint® supports, see File formats that are supported in PowerPoint on the Microsoft® website.
Properties
Picture file path, specified as a character vector or string scalar.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Data Types: char | string
Internal or external hyperlink target for the picture, specified as an
integer, string scalar, or character vector. Use an integer to specify the
index of the target slide in the presentation. To specify an external URL,
use a character vector or string scalar, and specify the fully qualified
URL. For example, include http://.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Data Types: int32 | char | string
Picture name, specified as a character vector or string scalar.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Data Types: char | string
Upper-left x-coordinate position, specified as a character vector or string scalar that contains
a number followed by an abbreviation for a unit of measurement. For example, "5in" specifies five inches. Valid
abbreviations are:
"px"— Pixels"cm"— Centimeters"in"— Inches"mm"— Millimeters"pc"— Picas"pt"— Points
You can also specify pixels by omitting the unit. For example, "5"
specifies 5 pixels.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Data Types: char | string
Upper-left y-coordinate position, specified as a character vector or string scalar that contains
a number followed by an abbreviation for a unit of measurement. For example, "5in" specifies five inches. Valid
abbreviations are:
"px"— Pixels"cm"— Centimeters"in"— Inches"mm"— Millimeters"pc"— Picas"pt"— Points
You can also specify pixels by omitting the unit. For example, "5"
specifies 5 pixels.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Data Types: char | string
Width of picture, specified as a
character vector or string scalar that contains a number followed by an
abbreviation for a unit of measurement. For example,
"5in" specifies five inches. Valid abbreviations
are:
"px"— Pixels"cm"— Centimeters"in"— Inches"mm"— Millimeters"pc"— Picas"pt"— Points
You can also specify pixels by omitting the unit. For example, "5"
specifies 5 pixels.
Note
When you replace a mlreportgen.ppt.ContentPlaceholder object in
a slide with the mlreportgen.ppt.Picture object, the dimensions of the
mlreportgen.ppt.Picture object are limited by the dimensions of the
ContentPlaceholder. If the value of the Width or
Height property is greater than the corresponding property of the
ContentPlaceholder object, the presentation automatically resizes both
the Width and Height properties to fit within the
dimensions of the ContentPlaceholder while retaining the aspect ratio of
the media. If you add the mlreportgen.ppt.Picture object directly to the slide, the
size of the media is limited to the size of the slide.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Data Types: char | string
Height of picture, specified as a
character vector or string scalar that contains a number followed by an
abbreviation for a unit of measurement. For example,
"5in" specifies five inches. Valid abbreviations
are:
"px"— Pixels"cm"— Centimeters"in"— Inches"mm"— Millimeters"pc"— Picas"pt"— Points
You can also specify pixels by omitting the unit. For example, "5"
specifies 5 pixels.
Note
When you replace a mlreportgen.ppt.ContentPlaceholder object in
a slide with the mlreportgen.ppt.Picture object, the dimensions of the
mlreportgen.ppt.Picture object are limited by the dimensions of the
ContentPlaceholder. If the value of the Width or
Height property is greater than the corresponding property of the
ContentPlaceholder object, the presentation automatically resizes both
the Width and Height properties to fit within the
dimensions of the ContentPlaceholder while retaining the aspect ratio of
the media. If you add the mlreportgen.ppt.Picture object directly to the slide, the
size of the media is limited to the size of the slide.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Data Types: char | string
Since R2026b
Border style, specified as one of the values in the table.
| Border Style | Description |
|---|---|
"" or "none" | No line |
"solid" | Solid line |
"dot" | Dotted line |
"dash" | Dashed line |
"largeDash" | Dashed line with large dashes |
"dashDot" | Line with alternating dashes and dots |
"largeDashDot" | Line with alternating large dashes and dots |
"largeDashDotDot" | Line with alternating large dashes and pairs of dots |
"systemDash" | Dashed line using the system-defined dash pattern |
"systemDot" | Dotted line using the system-defined dot pattern |
"systemDashDot" | Line with alternating dashes and dots using the system-defined pattern |
"systemDashDotDot" | Line with alternating dashes and pairs of dots using the system-defined pattern |
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Data Types: char | string
Since R2026b
Border color, specified as a character vector or string scalar that contains a CSS color name or hexadecimal RGB value.
| Format | Value |
|---|---|
| CSS color name | CSS color name. For a list of CSS color names, see https://www.w3.org/wiki/CSS/Properties/color/keywords. |
| Hexadecimal RGB value | RGB color in the format "#RRGGBB". Use # as the first
character and two-digit hexadecimal numbers for the red, green, and blue values.
You can use uppercase or lowercase letters. |
Example: "red" specifies a red color by using the CSS
color name.
Example: "#0000ff" specifies a blue color by using
the hexadecimal RGB value.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Data Types: char | string
Since R2026b
Border width, specified as a character vector or string scalar that contains
a number followed by an abbreviation for a unit of measurement. For example, "3pt" specifies three points. Valid
abbreviations are:
"px"— Pixels"cm"— Centimeters"in"— Inches"mm"— Millimeters"pc"— Picas"pt"— Points
You can also specify pixels by omitting the unit. For example, "5"
specifies 5 pixels.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Data Types: char | string
Border formatting, specified as a cell array that contains an mlreportgen.ppt.Border object.
Add Border objects by concatenating the existing value of the
Style property with a cell array that contains the Border objects
that you want to add.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Data Types: cell
Parent of this object, specified as a PPT API object. A PPT API object must only have one parent.
Attributes:
GetAccess | public |
SetAccess | private |
NonCopyable | true |
Child elements of this object, specified as a cell array of PPT API objects.
Attributes:
GetAccess | public |
SetAccess | private |
NonCopyable | true |
Data Types: cell
Tag, specified as a character vector or string scalar. The PPT API generates a
session-unique tag as part of the creation of this object. The generated tag has the
form CLASS:ID, where
CLASS is the object class and
ID is the value of the
Id property of the object. Use this value to help identify
where an issue occurs during presentation generation.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Data Types: char | string
Object identifier, specified as a character vector or string scalar. The PPT API
generates a session-unique identifier when it creates the presentation element object.
You can specify your own value for Id.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Data Types: char | string
Methods
|
Input Arguments
Return Values
For more information, see the method for the
Example: Replace a Picture |
|
Input Arguments
Return Values
For more information, see the method for the
|
Examples
Use an mlreportgen.ppt.Picture object to include a picture of an airplane in a presentation.
Create a presentation.
import mlreportgen.ppt.* ppt = Presentation("myPicturePresentation.pptx"); open(ppt);
Add a slide with a Title and Content layout to the presentation.
add(ppt,"Title and Content");Create a Picture object using an image of an airplane. Specify the size of the picture.
plane = Picture(which("b747.jpg")); plane.Width = "5in"; plane.Height = "2in";
Replace the content of the slide with the picture.
replace(ppt,"Content",plane);Close and view the presentation.
close(ppt); rptview(ppt);
Here is the generated slide with the image of the airplane:

To add an image of a MATLAB® figure to a presentation, this example prints the figure to an
image file, creates an mlreportgen.ppt.Picture object from
the file, and adds the Picture object to a slide in the
presentation.
Create a presentation.
import mlreportgen.ppt.* ppt = Presentation("myFigurePresentation.pptx"); open(ppt);
Add a slide to the presentation.
slide = add(ppt,"Title and Content");Add a title to the slide.
replace(slide,"Title","surf(peaks)");
Create a MATLAB figure with a surface plot.
fig = figure; surf(peaks);
Print the figure to an image file. Before generating the presentation, do not delete the image file.
figSnapshotImage = "figSnapshot.png"; print(fig,"-dpng",figSnapshotImage);
Create an mlreportgen.ppt.Picture object using the
image file.
figPicture = Picture(figSnapshotImage);
Add the Picture object to the slide.
replace(slide,"Content",figPicture);Close the presentation.
close(ppt);
Delete the figure and the image file.
delete(fig); delete(figSnapshotImage);
View the presentation.
rptview(ppt);
Here is the generated slide with the image of the figure:

Replace a picture in a presentation.
Create a presentation.
import mlreportgen.ppt.* ppt = Presentation("myPictureReplacePresentation"); slide1 = add(ppt,"Blank");
Create an mlreportgen.ppt.Picture object.
plane = Picture(which("b747.jpg")); plane.X = "1in"; plane.Y = "1in"; plane.Width = "5in"; plane.Height = "2in";
Add the picture to the slide.
add(slide1,plane);
Create a second picture.
peppers = Picture(which("peppers.png")); peppers.X = "1in"; peppers.Y = "1in"; peppers.Width = "3in"; peppers.Height = "3in";
Replace the plane picture with the peppers picture.
replace(plane,peppers);
Close and view the presentation.
close(ppt); rptview(ppt);
Since R2026b
To customize the border of a picture in a PPT API presentation, specify
the border style, color, and width in an mlreportgen.ppt.Border object and
add the object to the Style property of an
mlreportgen.ppt.Picture object.
Create a presentation.
import mlreportgen.ppt.* ppt = Presentation("myPictureBorder.pptx"); open(ppt);
Add a slide to the presentation.
slide = add(ppt,"Title and Picture");Create a picture.
pic = Picture(which("peppers.png"));Create a border object and apply it to the picture.
border = Border("solid","red","3pt"); pic.Style = [pic.Style {border}];
Add a title and the picture to the slide.
replace(slide,"Title","Picture with a custom border"); replace(slide,"Picture",pic);
Close and view the presentation.
close(ppt); rptview(ppt);
Version History
Introduced in R2015bAdd borders to pictures in presentations by using the Border,
BorderColor, BorderWidth, and
Style properties.
Report Generator no longer supports BMP (bitmap) as an output image format. This affects
snapshots, images from files, and watermarks in both the Report Explorer and the Report,
DOM, and PPT APIs. See print for more information.
The mlreportgen.ppt.Picture class supports Scalable Vector Graphics
(SVG) images. To verify that your version of PowerPoint supports SVG images, see File formats that are supported in PowerPoint on the Microsoft website.
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Sélectionner un site web
Choisissez un site web pour accéder au contenu traduit dans votre langue (lorsqu'il est disponible) et voir les événements et les offres locales. D’après votre position, nous vous recommandons de sélectionner la région suivante : .
Vous pouvez également sélectionner un site web dans la liste suivante :
Comment optimiser les performances du site
Pour optimiser les performances du site, sélectionnez la région Chine (en chinois ou en anglais). Les sites de MathWorks pour les autres pays ne sont pas optimisés pour les visites provenant de votre région.
Amériques
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)