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
{
$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.
*/
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);
}
/**
"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",
],
"time": "2023-12-03T19:50:20+00:00"
},
+ {
+ "name": "intervention/gif",
+ "version": "4.0.2",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/Intervention/gif.git",
+ "reference": "c2b07d1f69709e196c8b4ced423449a7e0f3b925"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/Intervention/gif/zipball/c2b07d1f69709e196c8b4ced423449a7e0f3b925",
+ "reference": "c2b07d1f69709e196c8b4ced423449a7e0f3b925",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^8.1"
+ },
+ "require-dev": {
+ "phpstan/phpstan": "^1",
+ "phpunit/phpunit": "^9",
+ "slevomat/coding-standard": "~8.0",
+ "squizlabs/php_codesniffer": "^3.8"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Intervention\\Gif\\": "src"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Oliver Vogel",
+ "homepage": "https://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/4.0.2"
+ },
+ "funding": [
+ {
+ "url": "https://paypal.me/interventionio",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/Intervention",
+ "type": "github"
+ }
+ ],
+ "time": "2024-02-18T15:36:58+00:00"
+ },
{
"name": "intervention/image",
- "version": "2.7.2",
+ "version": "3.5.0",
"source": {
"type": "git",
"url": "https://github.com/Intervention/image.git",
- "reference": "04be355f8d6734c826045d02a1079ad658322dad"
+ "reference": "408d3655c7705339e8c79731ea7efb51546cfa10"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/Intervention/image/zipball/04be355f8d6734c826045d02a1079ad658322dad",
- "reference": "04be355f8d6734c826045d02a1079ad658322dad",
+ "url": "https://api.github.com/repos/Intervention/image/zipball/408d3655c7705339e8c79731ea7efb51546cfa10",
+ "reference": "408d3655c7705339e8c79731ea7efb51546cfa10",
"shasum": ""
},
"require": {
- "ext-fileinfo": "*",
- "guzzlehttp/psr7": "~1.1 || ^2.0",
- "php": ">=5.4.0"
+ "ext-mbstring": "*",
+ "intervention/gif": "^4.0.1",
+ "php": "^8.1"
},
"require-dev": {
- "mockery/mockery": "~0.9.2",
- "phpunit/phpunit": "^4.8 || ^5.7 || ^7.5.15"
+ "mockery/mockery": "^1.6",
+ "phpstan/phpstan": "^1",
+ "phpunit/phpunit": "^10.0",
+ "slevomat/coding-standard": "~8.0",
+ "squizlabs/php_codesniffer": "^3.8"
},
"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"
+ "ext-exif": "Recommended to be able to read EXIF data properly."
},
"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\\Image\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"homepage": "https://intervention.io/"
}
],
- "description": "Image handling and manipulation library with support for Laravel integration",
- "homepage": "http://image.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.5.0"
},
"funding": [
{
"type": "github"
}
],
- "time": "2022-05-21T17:30:32+00:00"
+ "time": "2024-03-13T16:26:15+00:00"
},
{
"name": "knplabs/knp-snappy",