File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed
src/PhpPresentation/Shape/Drawing Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -301,17 +301,17 @@ public function __destruct()
301
301
*/
302
302
public function loadFromContent (string $ content , string $ fileName = '' , string $ prefix = 'PhpPresentationGd ' ): AbstractDrawingAdapter
303
303
{
304
+ // Check if the content is a valid image
304
305
$ image = @imagecreatefromstring ($ content );
305
306
if ($ image === false ) {
306
307
return $ this ;
307
308
}
309
+ // Clean up the image resource to avoid memory leaks
310
+ @imagedestroy ($ image );
308
311
309
312
$ tmpFile = tempnam (sys_get_temp_dir (), $ prefix );
310
313
file_put_contents ($ tmpFile , $ content );
311
314
312
- // Set image resource
313
- $ this ->setImageResource ($ image );
314
-
315
315
// Set path and mark as temporary for automatic cleanup
316
316
$ this ->setPath ($ tmpFile );
317
317
$ this ->setIsTemporaryFile (true );
You can’t perform that action at this time.
0 commit comments