@@ -270,12 +270,14 @@ protected function loadStyle(DOMElement $nodeStyle): bool
270
270
if ('bitmap ' == $ nodeDrawingPageProps ->getAttribute ('draw:fill ' ) && $ nodeDrawingPageProps ->hasAttribute ('draw:fill-image-name ' )) {
271
271
$ nameStyle = $ nodeDrawingPageProps ->getAttribute ('draw:fill-image-name ' );
272
272
if (!empty ($ this ->arrayCommonStyles [$ nameStyle ]) && 'image ' == $ this ->arrayCommonStyles [$ nameStyle ]['type ' ] && !empty ($ this ->arrayCommonStyles [$ nameStyle ]['path ' ])) {
273
- $ tmpBkgImg = tempnam (sys_get_temp_dir (), 'PhpPresentationReaderODPBkg ' );
274
273
$ contentImg = $ this ->oZip ->getFromName ($ this ->arrayCommonStyles [$ nameStyle ]['path ' ]);
275
- file_put_contents ($ tmpBkgImg , $ contentImg );
274
+ if ($ contentImg ) {
275
+ $ tmpFile = new Gd ();
276
+ $ tmpFile ->loadFromContent ($ contentImg , basename ($ this ->arrayCommonStyles [$ nameStyle ]['path ' ]));
276
277
277
- $ oBackground = new Image ();
278
- $ oBackground ->setPath ($ tmpBkgImg );
278
+ $ oBackground = new Image ();
279
+ $ oBackground ->setImage ($ tmpFile );
280
+ }
279
281
}
280
282
}
281
283
}
@@ -584,7 +586,7 @@ protected function loadShapeDrawing(DOMElement $oNodeFrame): void
584
586
// Contents of file
585
587
if (empty ($ mimetype )) {
586
588
$ shape = new Gd ();
587
- $ shape ->setImageResource ( imagecreatefromstring ( $ imageFile ));
589
+ $ shape ->loadFromContent ( $ imageFile, basename ( $ sFilename ));
588
590
} else {
589
591
$ shape = new Base64 ();
590
592
$ shape ->setData ('data: ' . $ mimetype . ';base64, ' . base64_encode ($ imageFile ));
@@ -668,13 +670,12 @@ protected function loadShapeMedia(DOMElement $oNodeFrame): void
668
670
$ mediaFile = $ this ->oZip ->getFromName ($ filePath );
669
671
}
670
672
671
- $ tmpEmbed = tempnam (sys_get_temp_dir (), 'PhpPresentationReaderODPEmbed ' );
672
- file_put_contents ($ tmpEmbed , $ mediaFile );
673
+ if (!$ mediaFile ) {
674
+ return ;
675
+ }
673
676
674
677
$ shape = new Media ();
675
- $ shape
676
- ->setFileName (basename ($ filePath ))
677
- ->setPath ($ tmpEmbed , false );
678
+ $ shape ->loadFromContent ($ mediaFile , basename ($ filePath ));
678
679
679
680
$ shape ->getShadow ()->setVisible (false );
680
681
$ shape ->setName ($ oNodeFrame ->hasAttribute ('draw:name ' ) ? $ oNodeFrame ->getAttribute ('draw:name ' ) : '' );
0 commit comments