Skip to content

Commit

Permalink
Fixed Driver issues on Intervention Image 3
Browse files Browse the repository at this point in the history
  • Loading branch information
ithsjeff authored Aug 15, 2024
1 parent 1738b60 commit 5a49e45
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/CaptchaServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
namespace Mews\Captcha;

use Illuminate\Routing\Router;
use Illuminate\Support\ServiceProvider;
use Illuminate\Validation\Factory;
use Intervention\Image\Drivers\Gd\Driver;
use Intervention\Image\ImageManager;
use Illuminate\Support\ServiceProvider;
use Intervention\Image\Drivers\Gd\Driver as GdDriver;
use Intervention\Image\Drivers\Imagick\Driver as ImagickDriver;

/**
* Class CaptchaServiceProvider
Expand Down Expand Up @@ -72,9 +74,13 @@ public function register(): void
'captcha'
);

if (!$this->app->bound('Intervention\Image\ImageManager')) {
// Bind the ImageManager with an explicit driver
if (!$this->app->bound('Intervention\Image\ImageManager')) {
$this->app->singleton('Intervention\Image\ImageManager', function ($app) {
return new \Intervention\Image\ImageManager(new Driver());
// Determine which driver to use, defaulting to 'gd'
$driver = config('captcha.driver', 'gd') === 'imagick' ? new ImagickDriver() : new GdDriver();

return new ImageManager($driver);
});
}

Expand Down

0 comments on commit 5a49e45

Please sign in to comment.