33namespace Ladmin \Form \Field ;
44
55use Illuminate \Support \Str ;
6- use Intervention \Image \Constraint ;
7- use Intervention \Image \Facades \ Image as InterventionImage ;
8- use Intervention \Image \ImageManagerStatic ;
6+ use Intervention \Image \Drivers \ Gd \ Driver as GdDriver ;
7+ use Intervention \Image \Image as InterventionImage ;
8+ use Intervention \Image \ImageManager ;
99use Symfony \Component \HttpFoundation \File \UploadedFile ;
1010
1111trait ImageField
@@ -44,14 +44,17 @@ public function defaultDirectory()
4444 public function callInterventionMethods ($ target )
4545 {
4646 if (!empty ($ this ->interventionCalls )) {
47- $ image = ImageManagerStatic::make ($ target );
47+ $ manager = new ImageManager (new GdDriver ());
48+ $ image = $ manager ->read ($ target );
4849
4950 foreach ($ this ->interventionCalls as $ call ) {
5051 call_user_func_array (
5152 [$ image , $ call ['method ' ]],
5253 $ call ['arguments ' ]
53- )-> save ( $ target ) ;
54+ );
5455 }
56+
57+ $ image ->save ($ target );
5558 }
5659
5760 return $ target ;
@@ -73,7 +76,7 @@ public function __call($method, $arguments)
7376 return $ this ;
7477 }
7578
76- if (!class_exists (ImageManagerStatic ::class)) {
79+ if (!class_exists (ImageManager ::class)) {
7780 throw new \Exception ('To use image handling and manipulation, please install [intervention/image] first. ' );
7881 }
7982
@@ -189,13 +192,12 @@ protected function uploadAndDeleteOriginalThumbnail(UploadedFile $file)
189192 $ path = $ path . '- ' . $ name . '. ' . $ ext ;
190193
191194 /** @var \Intervention\Image\Image $image */
192- $ image = InterventionImage::make ($ file );
195+ $ manager = new ImageManager (new GdDriver ());
196+ $ image = $ manager ->read ($ file );
193197
194198 $ action = $ size [2 ] ?? 'resize ' ;
195199 // Resize image with aspect ratio
196- $ image ->$ action ($ size [0 ], $ size [1 ], function (Constraint $ constraint ) {
197- $ constraint ->aspectRatio ();
198- })->resizeCanvas ($ size [0 ], $ size [1 ], 'center ' , false , '#ffffff ' );
200+ $ image ->$ action ($ size [0 ], $ size [1 ])->resizeCanvas ($ size [0 ], $ size [1 ], 'center ' , false , '#ffffff ' );
199201
200202 if (!is_null ($ this ->storagePermission )) {
201203 $ this ->storage ->put ("{$ this ->getDirectory ()}/ {$ path }" , $ image ->encode (), $ this ->storagePermission );
0 commit comments