Update Intervention/Image class to v3

This commit is contained in:
Jonny Barnes 2023-12-17 13:56:10 +00:00
parent 58a03ef931
commit 6d5b298837
Signed by: jonny
SSH key fingerprint: SHA256:CTuSlns5U7qlD9jqHvtnVmfYV3Zwl2Z7WnJ4/dqOaL8
6 changed files with 84 additions and 46 deletions

View file

@ -18,7 +18,7 @@ use Illuminate\Http\UploadedFile;
use Illuminate\Support\Carbon; use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use Intervention\Image\Exception\NotReadableException; use Intervention\Image\Exceptions\DecoderException;
use Intervention\Image\ImageManager; use Intervention\Image\ImageManager;
use Lcobucci\JWT\Token\InvalidTokenStructure; use Lcobucci\JWT\Token\InvalidTokenStructure;
use Lcobucci\JWT\Validation\RequiredConstraintsViolated; use Lcobucci\JWT\Validation\RequiredConstraintsViolated;
@ -108,7 +108,7 @@ class MicropubMediaController extends Controller
{ {
try { try {
$tokenData = $this->tokenService->validateToken($request->input('access_token')); $tokenData = $this->tokenService->validateToken($request->input('access_token'));
} catch (RequiredConstraintsViolated|InvalidTokenStructure $exception) { } catch (RequiredConstraintsViolated|InvalidTokenStructure) {
$micropubResponses = new MicropubResponses(); $micropubResponses = new MicropubResponses();
return $micropubResponses->invalidTokenResponse(); return $micropubResponses->invalidTokenResponse();
@ -144,11 +144,12 @@ class MicropubMediaController extends Controller
$filename = $this->saveFile($request->file('file')); $filename = $this->saveFile($request->file('file'));
/** @var ImageManager $manager */
$manager = resolve(ImageManager::class); $manager = resolve(ImageManager::class);
try { try {
$image = $manager->make($request->file('file')); $image = $manager->read($request->file('file'));
$width = $image->width(); $width = $image->width();
} catch (NotReadableException $exception) { } catch (DecoderException) {
// not an image // not an image
$width = null; $width = null;
} }

View file

@ -10,7 +10,7 @@ use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels; use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
use Intervention\Image\Exception\NotReadableException; use Intervention\Image\Exceptions\DecoderException;
use Intervention\Image\ImageManager; use Intervention\Image\ImageManager;
class ProcessMedia implements ShouldQueue class ProcessMedia implements ShouldQueue
@ -35,8 +35,8 @@ class ProcessMedia implements ShouldQueue
{ {
//open file //open file
try { try {
$image = $manager->make(storage_path('app') . '/' . $this->filename); $image = $manager->read(storage_path('app') . '/' . $this->filename);
} catch (NotReadableException $exception) { } catch (DecoderException) {
// not an image; delete file and end job // not an image; delete file and end job
unlink(storage_path('app') . '/' . $this->filename); unlink(storage_path('app') . '/' . $this->filename);

View file

@ -30,7 +30,7 @@ class AppServiceProvider extends ServiceProvider
// configure Intervention/Image // configure Intervention/Image
$this->app->bind('Intervention\Image\ImageManager', function () { $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 // Bind the Codebird client

View file

@ -13,7 +13,7 @@
"cviebrock/eloquent-sluggable": "^10.0", "cviebrock/eloquent-sluggable": "^10.0",
"guzzlehttp/guzzle": "^7.2", "guzzlehttp/guzzle": "^7.2",
"indieauth/client": "^1.1", "indieauth/client": "^1.1",
"intervention/image": "^2.4", "intervention/image": "^3",
"jonnybarnes/indieweb": "~0.2", "jonnybarnes/indieweb": "~0.2",
"jonnybarnes/webmentions-parser": "~0.5", "jonnybarnes/webmentions-parser": "~0.5",
"jublonet/codebird-php": "4.0.0-beta.1", "jublonet/codebird-php": "4.0.0-beta.1",

107
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "cee34851c8b229497a4bd596d4b02047", "content-hash": "ed959f0ebfc2cffaf227b9ed7e3457a8",
"packages": [ "packages": [
{ {
"name": "aws/aws-crt-php", "name": "aws/aws-crt-php",
@ -1643,50 +1643,30 @@
"time": "2023-05-24T15:33:06+00:00" "time": "2023-05-24T15:33:06+00:00"
}, },
{ {
"name": "intervention/image", "name": "intervention/gif",
"version": "2.7.2", "version": "3.0.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/Intervention/image.git", "url": "https://github.com/Intervention/gif.git",
"reference": "04be355f8d6734c826045d02a1079ad658322dad" "reference": "cfececc760862f075a52acf747031bad08c8301b"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/Intervention/image/zipball/04be355f8d6734c826045d02a1079ad658322dad", "url": "https://api.github.com/repos/Intervention/gif/zipball/cfececc760862f075a52acf747031bad08c8301b",
"reference": "04be355f8d6734c826045d02a1079ad658322dad", "reference": "cfececc760862f075a52acf747031bad08c8301b",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"ext-fileinfo": "*", "php": "^8.0"
"guzzlehttp/psr7": "~1.1 || ^2.0",
"php": ">=5.4.0"
}, },
"require-dev": { "require-dev": {
"mockery/mockery": "~0.9.2", "phpstan/phpstan": "^1",
"phpunit/phpunit": "^4.8 || ^5.7 || ^7.5.15" "phpunit/phpunit": "^9"
},
"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"
}, },
"type": "library", "type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.4-dev"
},
"laravel": {
"providers": [
"Intervention\\Image\\ImageServiceProvider"
],
"aliases": {
"Image": "Intervention\\Image\\Facades\\Image"
}
}
},
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"Intervention\\Image\\": "src/Intervention/Image" "Intervention\\Gif\\": "src"
} }
}, },
"notification-url": "https://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
@ -1700,19 +1680,74 @@
"homepage": "https://intervention.io/" "homepage": "https://intervention.io/"
} }
], ],
"description": "Image handling and manipulation library with support for Laravel integration", "description": "Native PHP GIF Encoder/Decoder",
"homepage": "http://image.intervention.io/", "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": [ "keywords": [
"gd", "gd",
"image", "image",
"imagick", "imagick",
"laravel", "resize",
"thumbnail", "thumbnail",
"watermark" "watermark"
], ],
"support": { "support": {
"issues": "https://github.com/Intervention/image/issues", "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": [ "funding": [
{ {
@ -1724,7 +1759,7 @@
"type": "github" "type": "github"
} }
], ],
"time": "2022-05-21T17:30:32+00:00" "time": "2023-12-16T14:21:10+00:00"
}, },
{ {
"name": "jonnybarnes/indieweb", "name": "jonnybarnes/indieweb",

View file

@ -1,5 +1,7 @@
<?php <?php
use Intervention\Image\Drivers\Gd\Driver;
return [ return [
/* /*
@ -15,6 +17,6 @@ return [
| |
*/ */
'driver' => 'gd', 'driver' => Driver::class,
]; ];