1
0
Fork 0
mirror of https://github.com/archtechx/laravel-seo.git synced 2026-05-06 09:44:03 +00:00

Intervention Image v3 support (#45)

* fix: type error to assign the drie for image manager class

* fix: update package names and handle Intervention Image versioning in favicon generation

* fix: update intervention/image version constraint in composer.json

* cleanup, run CI tests with both intervention v2 and v3

* ci: composer require --dev

* phpstan fixes

---------

Co-authored-by: Samuel Štancl <samuel@archte.ch>
This commit is contained in:
Al Amin Ahamed 2026-03-31 07:48:26 +06:00 committed by GitHub
parent f79d417145
commit 713ecea0d5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 38 additions and 17 deletions

View file

@ -37,22 +37,40 @@ class GenerateFaviconsCommand extends Command
return self::FAILURE;
}
// GD driver doesn't support .ico, that's why we use ImageMagick.
$manager = new ImageManager(['driver' => 'imagick']);
// Check Intervention Image version
$interventionV3 = interface_exists('\Intervention\Image\Interfaces\DriverInterface');
$this->comment('Generating ico...');
if ($interventionV3) {
// v3.x implementation
$manager = new ImageManager(
new \Intervention\Image\Drivers\Imagick\Driver()
);
$manager
->make($path)
->resize(32, 32)
->save(public_path('favicon.ico'));
$this->comment('Generating ico...');
$image = $manager->read($path);
$image->resize(32, 32);
$image->save(public_path('favicon.ico'));
$this->comment('Generating png...');
$this->comment('Generating png...');
$image = $manager->read($path);
$image->resize(32, 32);
$image->save(public_path('favicon.png'));
} else {
// v2.x implementation
$manager = new ImageManager(['driver' => 'imagick']); // @phpstan-ignore argument.type
$manager
->make($path)
->resize(32, 32)
->save(public_path('favicon.png'));
$this->comment('Generating ico...');
$manager
->make($path) // @phpstan-ignore method.notFound
->resize(32, 32)
->save(public_path('favicon.ico'));
$this->comment('Generating png...');
$manager
->make($path) // @phpstan-ignore method.notFound
->resize(32, 32)
->save(public_path('favicon.png'));
}
$this->info('All favicons have been generated!');