Skip to content

Commit 56668da

Browse files
[3.x] Migrate to v3 of intervention/image and Laravel 12 support (#24)
* Chore(deps): migrate to intervention/image v3 * Chore(laravel): add support for Laravel 12 * Formatting
1 parent 48aa51c commit 56668da

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@
2323
],
2424
"require": {
2525
"php": "^8.1",
26-
"illuminate/support": "^10.0|^11.0",
27-
"intervention/image": "^2.7|^3.4",
28-
"illuminate/container": "^10.0|^11.0",
29-
"illuminate/contracts": "^10.0|^11.0",
26+
"illuminate/support": "^10.0|^11.0|^12.0",
27+
"intervention/image": "^3.4",
28+
"illuminate/container": "^10.0|^11.0|^12.0",
29+
"illuminate/contracts": "^10.0|^11.0|^12.0",
3030
"ext-fileinfo": "*"
3131
},
3232
"require-dev": {
33-
"orchestra/testbench": "^8.0|^9.0"
33+
"orchestra/testbench": "^8.0|^9.0|^10.0"
3434
},
3535
"autoload": {
3636
"psr-4": {

src/ImageSanitize.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22

33
namespace LaravelAt\ImageSanitize;
44

5-
use Intervention\Image\Image;
5+
use Intervention\Image\Drivers\Gd\Driver;
6+
use Intervention\Image\EncodedImage;
7+
use Intervention\Image\Encoders\AutoEncoder;
68
use Intervention\Image\ImageManager;
79
use LaravelAt\ImageSanitize\Lists\PatternList;
810

911
class ImageSanitize
1012
{
1113
public function __construct(
12-
protected ImageManager $imageManager,
1314
protected PatternList $patternList,
1415
) {
1516
}
@@ -25,8 +26,12 @@ public function detect(string $content): bool
2526
return false;
2627
}
2728

28-
public function sanitize(string $content): Image
29+
public function sanitize(string $content): EncodedImage
2930
{
30-
return $this->imageManager->make($content)->encode(null, 100);
31+
$imageManager = new ImageManager(new Driver());
32+
33+
$image = $imageManager->read($content);
34+
35+
return $image->encode(new AutoEncoder(quality: 100));
3136
}
3237
}

0 commit comments

Comments
 (0)