Deps: Updated intervention library from 2 to 3

Major version change, required some changes to API
For #4903
This commit is contained in:
Dan Brown 2024-03-17 16:03:12 +00:00
parent 3250fc732c
commit 2345fd4677
No known key found for this signature in database
GPG Key ID: 46D9F943C24A2EF9
3 changed files with 111 additions and 52 deletions

View File

@ -6,8 +6,12 @@ use BookStack\Exceptions\ImageUploadException;
use Exception;
use GuzzleHttp\Psr7\Utils;
use Illuminate\Support\Facades\Cache;
use Intervention\Image\Gd\Driver;
use Intervention\Image\Image as InterventionImage;
use Intervention\Image\Decoders\BinaryImageDecoder;
use Intervention\Image\Drivers\Gd\Driver;
use Intervention\Image\Encoders\AutoEncoder;
use Intervention\Image\Encoders\PngEncoder;
use Intervention\Image\Interfaces\ImageInterface as InterventionImage;
use Intervention\Image\ImageManager;
class ImageResizer
{
@ -124,15 +128,17 @@ class ImageResizer
$this->orientImageToOriginalExif($thumb, $imageData);
if ($keepRatio) {
$thumb->resize($width, $height, function ($constraint) {
$constraint->aspectRatio();
$constraint->upsize();
});
$thumb->scaleDown($width, $height);
} else {
$thumb->fit($width, $height);
$thumb->cover($width, $height);
}
$thumbData = (string) $thumb->encode($format);
$encoder = match ($format) {
'png' => new PngEncoder(),
default => new AutoEncoder(),
};
$thumbData = (string) $thumb->encode($encoder);
// Use original image data if we're keeping the ratio
// and the resizing does not save any space.
@ -150,8 +156,9 @@ class ImageResizer
*/
protected function interventionFromImageData(string $imageData): InterventionImage
{
$driver = new Driver();
return $driver->decoder->initFromBinary($imageData);
$manager = new ImageManager(new Driver());
return $manager->read($imageData, BinaryImageDecoder::class);
}
/**

View File

@ -21,7 +21,7 @@
"barryvdh/laravel-snappy": "^1.0",
"doctrine/dbal": "^3.5",
"guzzlehttp/guzzle": "^7.4",
"intervention/image": "^2.7",
"intervention/image": "^3.5",
"laravel/framework": "^10.10",
"laravel/socialite": "^5.10",
"laravel/tinker": "^2.8",

134
composer.lock generated
View File

@ -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": "5c83a032875be7a7edcfd5a18264ac7d",
"content-hash": "e05f9f4344c239682f6a9fbab0f87cf0",
"packages": [
{
"name": "aws/aws-crt-php",
@ -1860,50 +1860,32 @@
"time": "2023-12-03T19:50:20+00:00"
},
{
"name": "intervention/image",
"version": "2.7.2",
"name": "intervention/gif",
"version": "4.0.2",
"source": {
"type": "git",
"url": "https://github.com/Intervention/image.git",
"reference": "04be355f8d6734c826045d02a1079ad658322dad"
"url": "https://github.com/Intervention/gif.git",
"reference": "c2b07d1f69709e196c8b4ced423449a7e0f3b925"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Intervention/image/zipball/04be355f8d6734c826045d02a1079ad658322dad",
"reference": "04be355f8d6734c826045d02a1079ad658322dad",
"url": "https://api.github.com/repos/Intervention/gif/zipball/c2b07d1f69709e196c8b4ced423449a7e0f3b925",
"reference": "c2b07d1f69709e196c8b4ced423449a7e0f3b925",
"shasum": ""
},
"require": {
"ext-fileinfo": "*",
"guzzlehttp/psr7": "~1.1 || ^2.0",
"php": ">=5.4.0"
"php": "^8.1"
},
"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",
"slevomat/coding-standard": "~8.0",
"squizlabs/php_codesniffer": "^3.8"
},
"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/",
@ -1917,19 +1899,17 @@
"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",
"image",
"imagick",
"laravel",
"thumbnail",
"watermark"
"gif",
"image"
],
"support": {
"issues": "https://github.com/Intervention/image/issues",
"source": "https://github.com/Intervention/image/tree/2.7.2"
"issues": "https://github.com/Intervention/gif/issues",
"source": "https://github.com/Intervention/gif/tree/4.0.2"
},
"funding": [
{
@ -1941,7 +1921,79 @@
"type": "github"
}
],
"time": "2022-05-21T17:30:32+00:00"
"time": "2024-02-18T15:36:58+00:00"
},
{
"name": "intervention/image",
"version": "3.5.0",
"source": {
"type": "git",
"url": "https://github.com/Intervention/image.git",
"reference": "408d3655c7705339e8c79731ea7efb51546cfa10"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Intervention/image/zipball/408d3655c7705339e8c79731ea7efb51546cfa10",
"reference": "408d3655c7705339e8c79731ea7efb51546cfa10",
"shasum": ""
},
"require": {
"ext-mbstring": "*",
"intervention/gif": "^4.0.1",
"php": "^8.1"
},
"require-dev": {
"mockery/mockery": "^1.6",
"phpstan/phpstan": "^1",
"phpunit/phpunit": "^10.0",
"slevomat/coding-standard": "~8.0",
"squizlabs/php_codesniffer": "^3.8"
},
"suggest": {
"ext-exif": "Recommended to be able to read EXIF data properly."
},
"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",
"resize",
"thumbnail",
"watermark"
],
"support": {
"issues": "https://github.com/Intervention/image/issues",
"source": "https://github.com/Intervention/image/tree/3.5.0"
},
"funding": [
{
"url": "https://paypal.me/interventionio",
"type": "custom"
},
{
"url": "https://github.com/Intervention",
"type": "github"
}
],
"time": "2024-03-13T16:26:15+00:00"
},
{
"name": "knplabs/knp-snappy",