Practical phppptx
Images, audios and videos
Images, audios and videos can be added to presentations by calling their respective methods, stating the position and size for each content. Every method counts with specific options in order to apply styles to the new contents.
The method for adding new images in the internal active slide is addImage:
This method includes the following parameters:
- $image: image path, base64, stream or GdImage.
- $position: a new shape is generated to add the content. Coordinate and size values must be set.
- $imageStyles: image styles and additional attributes such as borders, hyperlinks, altText value and rotation.
- $options: extra options.
The following sample code adds a new image:
SVG contents can be added using addSvg.
If instead of inserting an image in the active slide you want to place it as background, use addBackgroundImage:
You have to indicate the image in it. For example:
As explained on Working with templates, phppptx includes methods to replace and remove images, audios and videos in templates.
When inserting audios and videos, you may place a predefined image added in phppptx as preview or use a custom image.
Coordinates, sizes and other options included in phppptx are shown in EMUs. Measure units such as PT or PX can be easily converted to EMUs. For more information on this matter, check the page EMUs measuring unit.