addImage

addImage

BASIC / ADVANCED / PREMIUM

Inserts an image into the PowerPoint presentation.

Description
public addImage($image, $position, $imageStyles = array(), $options = array())

This method inserts images (png, jpg, jpeg, gif, bmp) into the PowerPoint presentation.

Parameters

image

Image path, base64 or stream.

position

Key Type Description
new array

A new position is generated.

  • 'coordinateX' (int) EMUs (English Metric Unit).
  • 'coordinateY' (int) EMUs (English Metric Unit).
  • 'sizeX' (int) EMUs (English Metric Unit).
  • 'sizeY' (int) EMUs (English Metric Unit).
  • 'name' (string) placeholder internal name. If not set, a random name is generated.
  • 'order' (int) set the display order. Default after existing contents. 0 is the first order position. If the order position doesn't exist add after existing contents.

imageStyles

Key Type Description
border array
  • 'dash' (string) solid, dot, dash, lgDash, dashDot, lgDashDot, lgDashDotDot, sysDash, sysDot, sysDashDot, sysDashDotDot.
  • 'color' (string) default as 000000.
  • 'width' (int) EMUs (English Metric Unit). Default as 12700 (1pt).
descr string Descr value.
hyperlink string Hyperlink: external, bookmark (#firstslide, #lastslide, #nextslide, #previousslide) or slide (#slide + position)
rotation int Rotation value.

options

Key Type Description
mime string Forces a mime (image/jpg, image/jpeg, image/png, image/gif, image/bmp).
Exceptions

Image doesn't exist.

Image format is not supported.

Mime option is not set and getimagesizefromstring is not available.

Size not valid.

Hyperlink slide position not valid.

Position not valid.

Code samples

Example #1

The resulting PPTX looks like:

Release notes
  • phppptx 1.0:
    • new method.