Drawing

To create a drawing, you have four sources : File, GD, Base64 and ZipFile.

File

To create a drawing, use createDrawingShape method of slide.

$oShape = $oSlide->createDrawingShape();
$oShape->setName('Unique name')
        ->setDescription('Description of the drawing')
        ->setPath('/path/to/drawing.filename');

It’s an alias for :

use PhpOffice\PhpPresentation\Shape\Drawing\File;

$oShape = new File();
    $oShape->setName('Unique name')
            ->setDescription('Description of the drawing')
            ->setPath('/path/to/drawing.filename');
$oSlide->addShape($oShape);

GD

use PhpOffice\PhpPresentation\Shape\Drawing\Gd;

$gdImage = @imagecreatetruecolor($width, $height);

$oShape = new Gd();
$oShape->setName('Sample image')
    ->setDescription('Sample image')
    ->setImageResource($gdImage)
    ->setRenderingFunction(Drawing\Gd::RENDERING_JPEG)
    ->setMimeType(Drawing\Gd::MIMETYPE_DEFAULT);
$oSlide->addShape($oShape);

Base64

use PhpOffice\PhpPresentation\Shape\Drawing\Base64;

$oShape = new Base64();
$oShape->setName('Sample image')
    ->setDescription('Sample image')
    ->setImageResource($gdImage)
    ->setData('data:image/jpeg;base64,..........');
$oSlide->addShape($oShape);

ZipFile

use PhpOffice\PhpPresentation\Shape\Drawing\ZipFile;

$oShape = new ZipFile();
$oShape->setName('Sample image')
    ->setDescription('Sample image')
    ->setPath('zip://myzipfile.zip#path/in/zip/img.ext')
$oSlide->addShape($oShape);