diff --git a/src/Controllers/CropController.php b/src/Controllers/CropController.php index 3c7ed69e..b0f42a98 100644 --- a/src/Controllers/CropController.php +++ b/src/Controllers/CropController.php @@ -42,6 +42,7 @@ public function getCropImage($overWrite = true) $crop_info = request()->only('dataWidth', 'dataHeight', 'dataX', 'dataY'); // crop image + // TODO: support intervention/image v3 Image::make($image_path) ->crop(...array_values($crop_info)) ->save($crop_path); diff --git a/src/Controllers/ResizeController.php b/src/Controllers/ResizeController.php index 52092d14..db9df29c 100644 --- a/src/Controllers/ResizeController.php +++ b/src/Controllers/ResizeController.php @@ -65,6 +65,7 @@ public function performResize($overWrite = true) } event(new ImageIsResizing($image_path)); + // TODO: support intervention/image v3 Image::make($image_path)->resize(request('dataWidth'), request('dataHeight'))->save($resize_path); event(new ImageWasResized($image_path)); diff --git a/src/LfmPath.php b/src/LfmPath.php index 117c00fa..a82b2c3b 100644 --- a/src/LfmPath.php +++ b/src/LfmPath.php @@ -3,7 +3,8 @@ namespace UniSharp\LaravelFilemanager; use Illuminate\Container\Container; -use Intervention\Image\Facades\Image; +use Intervention\Image\Facades\Image as InterventionImageV2; +use Intervention\Image\Laravel\Facades\Image as InterventionImageV3; use Symfony\Component\HttpFoundation\File\UploadedFile; use UniSharp\LaravelFilemanager\Events\FileIsUploading; use UniSharp\LaravelFilemanager\Events\FileWasUploaded; @@ -234,7 +235,6 @@ public function upload($file) \Log::info($e); return $this->error('invalid'); } - // TODO should be "FileWasUploaded" event(new FileWasUploaded($new_file_path)); event(new ImageWasUploaded($new_file_path)); @@ -322,9 +322,19 @@ public function generateThumbnail($file_name) $this->setName($file_name)->thumb(true); $thumbWidth = $this->helper->shouldCreateCategoryThumb() && $this->helper->categoryThumbWidth() ? $this->helper->categoryThumbWidth() : config('lfm.thumb_img_width', 200); $thumbHeight = $this->helper->shouldCreateCategoryThumb() && $this->helper->categoryThumbHeight() ? $this->helper->categoryThumbHeight() : config('lfm.thumb_img_height', 200); - $image = Image::make($original_image->get()) - ->fit($thumbWidth, $thumbHeight); - $this->storage->put($image->stream()->detach(), 'public'); + if (class_exists(InterventionImageV2::class)) { + $encoded_image = InterventionImageV2::make($original_image->get()) + ->fit($thumbWidth, $thumbHeight) + ->stream() + ->detach(); + } else { + $encoded_image = InterventionImageV3::read($original_image->get()) + ->cover($thumbWidth, $thumbHeight) + ->encodeByMediaType(); + } + + + $this->storage->put($encoded_image, 'public'); } }