diff --git a/app/Http/Controllers/MicropubMediaController.php b/app/Http/Controllers/MicropubMediaController.php index 845f959c..5459a583 100644 --- a/app/Http/Controllers/MicropubMediaController.php +++ b/app/Http/Controllers/MicropubMediaController.php @@ -18,7 +18,7 @@ use Illuminate\Http\UploadedFile; use Illuminate\Support\Carbon; use Illuminate\Support\Facades\Storage; use Illuminate\Support\Str; -use Intervention\Image\Exception\NotReadableException; +use Intervention\Image\Exceptions\DecoderException; use Intervention\Image\ImageManager; use Lcobucci\JWT\Token\InvalidTokenStructure; use Lcobucci\JWT\Validation\RequiredConstraintsViolated; @@ -108,7 +108,7 @@ class MicropubMediaController extends Controller { try { $tokenData = $this->tokenService->validateToken($request->input('access_token')); - } catch (RequiredConstraintsViolated|InvalidTokenStructure $exception) { + } catch (RequiredConstraintsViolated|InvalidTokenStructure) { $micropubResponses = new MicropubResponses(); return $micropubResponses->invalidTokenResponse(); @@ -144,11 +144,12 @@ class MicropubMediaController extends Controller $filename = $this->saveFile($request->file('file')); + /** @var ImageManager $manager */ $manager = resolve(ImageManager::class); try { - $image = $manager->make($request->file('file')); + $image = $manager->read($request->file('file')); $width = $image->width(); - } catch (NotReadableException $exception) { + } catch (DecoderException) { // not an image $width = null; } diff --git a/app/Jobs/ProcessMedia.php b/app/Jobs/ProcessMedia.php index f35bdd1a..cb230c1e 100644 --- a/app/Jobs/ProcessMedia.php +++ b/app/Jobs/ProcessMedia.php @@ -10,7 +10,7 @@ use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; use Illuminate\Support\Facades\Storage; -use Intervention\Image\Exception\NotReadableException; +use Intervention\Image\Exceptions\DecoderException; use Intervention\Image\ImageManager; class ProcessMedia implements ShouldQueue @@ -35,8 +35,8 @@ class ProcessMedia implements ShouldQueue { //open file try { - $image = $manager->make(storage_path('app') . '/' . $this->filename); - } catch (NotReadableException $exception) { + $image = $manager->read(storage_path('app') . '/' . $this->filename); + } catch (DecoderException) { // not an image; delete file and end job unlink(storage_path('app') . '/' . $this->filename); diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 6e44fba1..9fb019ed 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -30,7 +30,7 @@ class AppServiceProvider extends ServiceProvider // configure Intervention/Image $this->app->bind('Intervention\Image\ImageManager', function () { - return new \Intervention\Image\ImageManager(['driver' => config('image.driver')]); + return \Intervention\Image\ImageManager::withDriver(config('image.driver')); }); // Bind the Codebird client diff --git a/composer.json b/composer.json index 33fc3dee..94312c9d 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ "cviebrock/eloquent-sluggable": "^10.0", "guzzlehttp/guzzle": "^7.2", "indieauth/client": "^1.1", - "intervention/image": "^2.4", + "intervention/image": "^3", "jonnybarnes/indieweb": "~0.2", "jonnybarnes/webmentions-parser": "~0.5", "jublonet/codebird-php": "4.0.0-beta.1", diff --git a/composer.lock b/composer.lock index 950842de..2365c328 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "cee34851c8b229497a4bd596d4b02047", + "content-hash": "ed959f0ebfc2cffaf227b9ed7e3457a8", "packages": [ { "name": "aws/aws-crt-php", @@ -1643,50 +1643,30 @@ "time": "2023-05-24T15:33:06+00:00" }, { - "name": "intervention/image", - "version": "2.7.2", + "name": "intervention/gif", + "version": "3.0.0", "source": { "type": "git", - "url": "https://github.com/Intervention/image.git", - "reference": "04be355f8d6734c826045d02a1079ad658322dad" + "url": "https://github.com/Intervention/gif.git", + "reference": "cfececc760862f075a52acf747031bad08c8301b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Intervention/image/zipball/04be355f8d6734c826045d02a1079ad658322dad", - "reference": "04be355f8d6734c826045d02a1079ad658322dad", + "url": "https://api.github.com/repos/Intervention/gif/zipball/cfececc760862f075a52acf747031bad08c8301b", + "reference": "cfececc760862f075a52acf747031bad08c8301b", "shasum": "" }, "require": { - "ext-fileinfo": "*", - "guzzlehttp/psr7": "~1.1 || ^2.0", - "php": ">=5.4.0" + "php": "^8.0" }, "require-dev": { - "mockery/mockery": "~0.9.2", - "phpunit/phpunit": "^4.8 || ^5.7 || ^7.5.15" - }, - "suggest": { - "ext-gd": "to use GD library based image processing.", - "ext-imagick": "to use Imagick based image processing.", - "intervention/imagecache": "Caching extension for the Intervention Image library" + "phpstan/phpstan": "^1", + "phpunit/phpunit": "^9" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.4-dev" - }, - "laravel": { - "providers": [ - "Intervention\\Image\\ImageServiceProvider" - ], - "aliases": { - "Image": "Intervention\\Image\\Facades\\Image" - } - } - }, "autoload": { "psr-4": { - "Intervention\\Image\\": "src/Intervention/Image" + "Intervention\\Gif\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -1700,19 +1680,74 @@ "homepage": "https://intervention.io/" } ], - "description": "Image handling and manipulation library with support for Laravel integration", - "homepage": "http://image.intervention.io/", + "description": "Native PHP GIF Encoder/Decoder", + "homepage": "https://github.com/intervention/gif", + "keywords": [ + "animation", + "gd", + "gif", + "image" + ], + "support": { + "issues": "https://github.com/Intervention/gif/issues", + "source": "https://github.com/Intervention/gif/tree/3.0.0" + }, + "time": "2023-11-27T18:54:30+00:00" + }, + { + "name": "intervention/image", + "version": "3.1.0", + "source": { + "type": "git", + "url": "https://github.com/Intervention/image.git", + "reference": "3de73efee5b1f96355f4d3ff4103411527a7cfb6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Intervention/image/zipball/3de73efee5b1f96355f4d3ff4103411527a7cfb6", + "reference": "3de73efee5b1f96355f4d3ff4103411527a7cfb6", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "intervention/gif": "^3", + "php": "^8.1" + }, + "require-dev": { + "mockery/mockery": "^1.6", + "phpstan/phpstan": "^1", + "phpunit/phpunit": "^9" + }, + "type": "library", + "autoload": { + "psr-4": { + "Intervention\\Image\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Oliver Vogel", + "email": "oliver@intervention.io", + "homepage": "https://intervention.io/" + } + ], + "description": "PHP image manipulation", + "homepage": "https://image.intervention.io/", "keywords": [ "gd", "image", "imagick", - "laravel", + "resize", "thumbnail", "watermark" ], "support": { "issues": "https://github.com/Intervention/image/issues", - "source": "https://github.com/Intervention/image/tree/2.7.2" + "source": "https://github.com/Intervention/image/tree/3.1.0" }, "funding": [ { @@ -1724,7 +1759,7 @@ "type": "github" } ], - "time": "2022-05-21T17:30:32+00:00" + "time": "2023-12-16T14:21:10+00:00" }, { "name": "jonnybarnes/indieweb", diff --git a/config/image.php b/config/image.php index 67983819..b984a0f0 100644 --- a/config/image.php +++ b/config/image.php @@ -1,5 +1,7 @@ 'gd', + 'driver' => Driver::class, ];