We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exception thrown trying to load powerpoint presentation due getimagesizefromstring($imageFile) returning false, rather than a valid array.
(ErrorException(code: 0): Trying to access array offset on value of type bool at /var/www/html/vendor/phpoffice/phppresentation/src/PhpPresentation/Reader/PowerPoint2007.php:805) [stacktrace] #0 /var/www/html/vendor/phpoffice/phppresentation/src/PhpPresentation/Reader/PowerPoint2007.php(805): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError() #1 /var/www/html/vendor/phpoffice/phppresentation/src/PhpPresentation/Reader/PowerPoint2007.php(1372): PhpOffice\PhpPresentation\Reader\PowerPoint2007->loadShapeDrawing() #2 /var/www/html/vendor/phpoffice/phppresentation/src/PhpPresentation/Reader/PowerPoint2007.php(506): PhpOffice\PhpPresentation\Reader\PowerPoint2007->loadSlideShapes() #3 /var/www/html/vendor/phpoffice/phppresentation/src/PhpPresentation/Reader/PowerPoint2007.php(396): PhpOffice\PhpPresentation\Reader\PowerPoint2007->loadMasterSlide() #4 /var/www/html/vendor/phpoffice/phppresentation/src/PhpPresentation/Reader/PowerPoint2007.php(353): PhpOffice\PhpPresentation\Reader\PowerPoint2007->loadMasterSlides() #5 /var/www/html/vendor/phpoffice/phppresentation/src/PhpPresentation/Reader/PowerPoint2007.php(169): PhpOffice\PhpPresentation\Reader\PowerPoint2007->loadSlides() #6 /var/www/html/vendor/phpoffice/phppresentation/src/PhpPresentation/Reader/PowerPoint2007.php(136): PhpOffice\PhpPresentation\Reader\PowerPoint2007->loadFile() #7 /var/www/html/app/Helpers/ParsePptx.php(35): PhpOffice\PhpPresentation\Reader\PowerPoint2007->load()
Code with issuein PowerPoint2007.php:
$pathImage = implode('/', $pathImage); $imageFile = $this->oZip->getFromName($pathImage); if (!empty($imageFile)) { if ($oShape instanceof Gd) { $info = getimagesizefromstring($imageFile); <============================================= $oShape->setMimeType($info['mime']); $oShape->setRenderingFunction(str_replace('/', '', $info['mime'])); $oShape->setImageResource(imagecreatefromstring($imageFile)); } elseif ($oShape instanceof Base64) { $oShape->setData('data:image/svg+xml;base64,' . base64_encode($imageFile)); } }
The text was updated successfully, but these errors were encountered:
It seems the image causing the problems is one on the slide master layer - and it's an .EMF image.
Sorry, something went wrong.
See #490 - same problem/feature request.
In the short term, as more people are seeing this - a simple:
if ($info !== false) { $oShape->setMimeType($info['mime']); $oShape->setRenderingFunction(str_replace('/', '', $info['mime'])); $oShape->setImageResource(imagecreatefromstring($imageFile)); }
stops the code from breaking and enables the reader to get the rest of the file.
Is this a permissible fix?
@websuasive Hi, Could you send me a sample file with error, please, for reproducing the bug ?
Hello, I'm facing the same problem.
Here's is a simple test file. test - Copie.pptx
No branches or pull requests
Exception thrown trying to load powerpoint presentation due getimagesizefromstring($imageFile) returning false, rather than a valid array.
(ErrorException(code: 0): Trying to access array offset on value of type bool at /var/www/html/vendor/phpoffice/phppresentation/src/PhpPresentation/Reader/PowerPoint2007.php:805)
[stacktrace]
#0 /var/www/html/vendor/phpoffice/phppresentation/src/PhpPresentation/Reader/PowerPoint2007.php(805): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError()
#1 /var/www/html/vendor/phpoffice/phppresentation/src/PhpPresentation/Reader/PowerPoint2007.php(1372): PhpOffice\PhpPresentation\Reader\PowerPoint2007->loadShapeDrawing()
#2 /var/www/html/vendor/phpoffice/phppresentation/src/PhpPresentation/Reader/PowerPoint2007.php(506): PhpOffice\PhpPresentation\Reader\PowerPoint2007->loadSlideShapes()
#3 /var/www/html/vendor/phpoffice/phppresentation/src/PhpPresentation/Reader/PowerPoint2007.php(396): PhpOffice\PhpPresentation\Reader\PowerPoint2007->loadMasterSlide()
#4 /var/www/html/vendor/phpoffice/phppresentation/src/PhpPresentation/Reader/PowerPoint2007.php(353): PhpOffice\PhpPresentation\Reader\PowerPoint2007->loadMasterSlides()
#5 /var/www/html/vendor/phpoffice/phppresentation/src/PhpPresentation/Reader/PowerPoint2007.php(169): PhpOffice\PhpPresentation\Reader\PowerPoint2007->loadSlides()
#6 /var/www/html/vendor/phpoffice/phppresentation/src/PhpPresentation/Reader/PowerPoint2007.php(136): PhpOffice\PhpPresentation\Reader\PowerPoint2007->loadFile()
#7 /var/www/html/app/Helpers/ParsePptx.php(35): PhpOffice\PhpPresentation\Reader\PowerPoint2007->load()
Code with issuein PowerPoint2007.php:
$pathImage = implode('/', $pathImage);
$imageFile = $this->oZip->getFromName($pathImage);
if (!empty($imageFile)) {
if ($oShape instanceof Gd) {
$info = getimagesizefromstring($imageFile); <=============================================
$oShape->setMimeType($info['mime']);
$oShape->setRenderingFunction(str_replace('/', '', $info['mime']));
$oShape->setImageResource(imagecreatefromstring($imageFile));
} elseif ($oShape instanceof Base64) {
$oShape->setData('data:image/svg+xml;base64,' . base64_encode($imageFile));
}
}
The text was updated successfully, but these errors were encountered: