@@ -361,21 +361,10 @@ public function createFromImage(string $image): GdImage|false
361361 parse_str (parse_url ($ image )['query ' ] ?? '' , $ query );
362362 $ path = is_array ($ query ['dir ' ]) ? $ query ['dir ' ]['0 ' ] : $ query ['dir ' ];
363363 $ image = ImageUtility::getRandomImageFromPath ($ path );
364- } elseif (!PathUtility::isUrl ($ image ) && !PathUtility::isAbsolutePath ($ image )) {
365- $ image = PathUtility::getAbsolutePath ($ image );
366364 }
367365
368366 if (!file_exists ($ image )) {
369- $ imageAlt1 = $ _SERVER ['DOCUMENT_ROOT ' ] . $ image ;
370- $ imageAlt2 = $ _SERVER ['DOCUMENT_ROOT ' ] . '/ ' . $ image ;
371-
372- if (file_exists ($ imageAlt1 )) {
373- $ image = $ imageAlt1 ;
374- } elseif (file_exists ($ imageAlt2 )) {
375- $ image = $ imageAlt2 ;
376- } else {
377- throw new \Exception ('File not found: ' . $ image );
378- }
367+ $ image = PathUtility::resolveFilePath ($ image );
379368 }
380369
381370 $ resource = imagecreatefromstring ((string )file_get_contents ($ image ));
@@ -761,22 +750,7 @@ public function applyText(GdImage $sourceResource): GdImage
761750 $ fontPath = $ tempFontPath ;
762751 $ isTempFont = true ;
763752 } else {
764- if (!PathUtility::isAbsolutePath ($ this ->fontPath )) {
765- $ fontPath = PathUtility::getAbsolutePath ($ this ->fontPath );
766- }
767-
768- if (!file_exists ($ fontPath )) {
769- $ fontAlt1 = $ _SERVER ['DOCUMENT_ROOT ' ] . $ this ->fontPath ;
770- $ fontAlt2 = $ _SERVER ['DOCUMENT_ROOT ' ] . '/ ' . $ this ->fontPath ;
771-
772- if (file_exists ($ fontAlt1 )) {
773- $ fontPath = $ fontAlt1 ;
774- } elseif (file_exists ($ fontAlt2 )) {
775- $ fontPath = $ fontAlt2 ;
776- } else {
777- throw new \Exception ('Font file not found: ' . $ fontPath );
778- }
779- }
753+ $ fontPath = PathUtility::resolveFilePath ($ this ->fontPath );
780754 }
781755
782756 // Add first line of text
0 commit comments