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 Exception;
use GuzzleHttp\Psr7\Utils; use GuzzleHttp\Psr7\Utils;
use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\Cache;
use Intervention\Image\Gd\Driver; use Intervention\Image\Decoders\BinaryImageDecoder;
use Intervention\Image\Image as InterventionImage; 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 class ImageResizer
{ {
@ -124,15 +128,17 @@ class ImageResizer
$this->orientImageToOriginalExif($thumb, $imageData); $this->orientImageToOriginalExif($thumb, $imageData);
if ($keepRatio) { if ($keepRatio) {
$thumb->resize($width, $height, function ($constraint) { $thumb->scaleDown($width, $height);
$constraint->aspectRatio();
$constraint->upsize();
});
} else { } 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 // Use original image data if we're keeping the ratio
// and the resizing does not save any space. // and the resizing does not save any space.
@ -150,8 +156,9 @@ class ImageResizer
*/ */
protected function interventionFromImageData(string $imageData): InterventionImage protected function interventionFromImageData(string $imageData): InterventionImage
{ {
$driver = new Driver(); $manager = new ImageManager(new Driver());
return $driver->decoder->initFromBinary($imageData);
return $manager->read($imageData, BinaryImageDecoder::class);
} }
/** /**

View File

@ -21,7 +21,7 @@
"barryvdh/laravel-snappy": "^1.0", "barryvdh/laravel-snappy": "^1.0",
"doctrine/dbal": "^3.5", "doctrine/dbal": "^3.5",
"guzzlehttp/guzzle": "^7.4", "guzzlehttp/guzzle": "^7.4",
"intervention/image": "^2.7", "intervention/image": "^3.5",
"laravel/framework": "^10.10", "laravel/framework": "^10.10",
"laravel/socialite": "^5.10", "laravel/socialite": "^5.10",
"laravel/tinker": "^2.8", "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", "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": "5c83a032875be7a7edcfd5a18264ac7d", "content-hash": "e05f9f4344c239682f6a9fbab0f87cf0",
"packages": [ "packages": [
{ {
"name": "aws/aws-crt-php", "name": "aws/aws-crt-php",
@ -1860,50 +1860,32 @@
"time": "2023-12-03T19:50:20+00:00" "time": "2023-12-03T19:50:20+00:00"
}, },
{ {
"name": "intervention/image", "name": "intervention/gif",
"version": "2.7.2", "version": "4.0.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/Intervention/image.git", "url": "https://github.com/Intervention/gif.git",
"reference": "04be355f8d6734c826045d02a1079ad658322dad" "reference": "c2b07d1f69709e196c8b4ced423449a7e0f3b925"
}, },
"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/c2b07d1f69709e196c8b4ced423449a7e0f3b925",
"reference": "04be355f8d6734c826045d02a1079ad658322dad", "reference": "c2b07d1f69709e196c8b4ced423449a7e0f3b925",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"ext-fileinfo": "*", "php": "^8.1"
"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",
}, "slevomat/coding-standard": "~8.0",
"suggest": { "squizlabs/php_codesniffer": "^3.8"
"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/",
@ -1917,19 +1899,17 @@
"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": [ "keywords": [
"animation",
"gd", "gd",
"image", "gif",
"imagick", "image"
"laravel",
"thumbnail",
"watermark"
], ],
"support": { "support": {
"issues": "https://github.com/Intervention/image/issues", "issues": "https://github.com/Intervention/gif/issues",
"source": "https://github.com/Intervention/image/tree/2.7.2" "source": "https://github.com/Intervention/gif/tree/4.0.2"
}, },
"funding": [ "funding": [
{ {
@ -1941,7 +1921,79 @@
"type": "github" "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", "name": "knplabs/knp-snappy",