PHPPresentation
PHPPresentation copied to clipboard
Error when adding images other than jpeg
So I've tried to add images using Base64 with jpeg file types and it works fine. But when I use png or svg+xml type it return this error:
Did the library is not yet supporting images other than jpeg?
thanks a lot
@Bagasdew Hi, Thank you for your issue. Could you check the develop branch ?
PNG support appears to have been added on the develop branch, but not SVG. I tried adding 'image/svg+xml' => 'svg', to https://github.com/PHPOffice/PHPPresentation/blob/develop/src/PhpPresentation/Shape/Drawing/Base64.php#L25 and it doesn't throw the exception, but I get this when loading the generated pptx in PowerPoint:

Any change of svg support being added as PowerPoint supports embedding SVG files?
@chriswheeler @Bagasdew @joelg99 Hi, Could you send me a PowerPoint file with a SVG image, for analysis, please ?
@Progi1984 - I have just emailed over an example. It actually works for the fist image embed with PNG or SVG but breaks for subsequent embeds.
Sorry, I've been working on this a bit more, and realised the root of the problem is that I was using the same 'Name' for each image.
$shape->setName('Image')
If I changed my code to give a unique name for each image, e.g.
$shape->setName('Image'.md5($svg))
It now works as expected.
Perhaps it would be worth throwing an exception or logging an error if the same name is reused and they need to be unique.