Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intervention Image Error #346

Closed
sgtcoder opened this issue Apr 8, 2024 · 14 comments
Closed

Intervention Image Error #346

sgtcoder opened this issue Apr 8, 2024 · 14 comments
Labels

Comments

@sgtcoder
Copy link

sgtcoder commented Apr 8, 2024

When installing Laravel 11 with Plank Mediable 6, I get this error:
Unresolvable dependency resolving [Parameter #0 [ <required> Intervention\Image\Interfaces\DriverInterface|string $driver ]] in class Intervention\Image\ImageManager

The fix I had to do was force intervention/image to be 2 vs the latest 3.

"intervention/image": "2.*",
@edux04
Copy link

edux04 commented Apr 8, 2024

I have the same issue, Laravel 11 and PHP 8.3.

@frasmage
Copy link
Collaborator

frasmage commented Apr 9, 2024

Hi there, so this isn't a bug with the package, it's just that Laravel doesn't know which driver to use when building Intervention image class without you telling it. It isn't really up to this package to pick for you, as you may have other code using the library already in place.

Adding the following to a service provider would be sufficient:

// for GD
$app->bind(Intervention\Image\Interfaces\DriverInterface::class, \Intervention\Image\Drivers\Gd\Driver::class);

// or for Imagick
$app->bind(Intervention\Image\Interfaces\DriverInterface::class, \Intervention\Image\Drivers\Imagick\Driver::class);

Preferably, you can use the intervention/image-laravel package to configure intervention/image, then Mediable will be able to load it from the container already set up.

I'm sure that others will run into similar issues, so I will add a note about this to the documentation. Thank you for bringing it to my attention

@sgtcoder
Copy link
Author

sgtcoder commented Apr 9, 2024

It works fine on Plank Mediable 5 and also on Image Intervention version 2.

We shouldn't need to make all these changes to get it to work.

@frasmage
Copy link
Collaborator

frasmage commented Apr 9, 2024

That is a change in the intervention/image package, not this one. Version 2 of intervention/image would automatically assume the use of GD as a driver, if no other was specified. Version 3 no longer makes that assumption, and requires a driver to be explicitly provided.

You are welcome to pin your application's composer.json to use "intervention/image": "^2.0" if you prefer that one. This package is compatible with both.

@sgtcoder
Copy link
Author

sgtcoder commented Apr 9, 2024

I am using Imagick with v2 and somehow it works.

Are you able to put that in your composer requirements?

So everyone doesn't have to run through this same issue?

@frasmage
Copy link
Collaborator

frasmage commented Apr 9, 2024

Some manual configuration was always necessary to use imagick:

  • Do you have a config/image.php file configuring which driver to use, such as the one described in this documentation? Previously the provider was built into the intervention/image package. With V3 this provider is extracted out into the intervention/image-laravel extension.
  • The docs of the this package suggested an alternative from prior to that provider being available (this needs to be updated for V3)

I don't think it make sense to require it (manual installation steps necessary), but I will add the intervention/image-laravel to the composer "suggest" list to provide the reminder. I will also update the docs accordingly with V3 instructions.

@sgtcoder
Copy link
Author

sgtcoder commented Apr 9, 2024

I actually was unaware that Plank was using GD by default or why it is even used in the first place?

I do use Imagick post processing to crop, compress, and scale the image. I know Plank doesn't do this.

@frasmage
Copy link
Collaborator

frasmage commented Apr 9, 2024

Tagged 6.0.2 with composer suggest and new documentation

@frasmage frasmage closed this as completed Apr 9, 2024
@frasmage
Copy link
Collaborator

frasmage commented Apr 9, 2024

plank/mediable uses intervention/image as it is available in the Laravel service container, it doesn't configure that 3rd party package for you. If you were previously doing no configuration, then you were using GD which was previously the default of that package.

Yes, the GD extension is capable of cropping and resizing images.

@sgtcoder
Copy link
Author

sgtcoder commented Apr 9, 2024

I get that GD is capable of cropping and resizing, but what is Plank using it for?

I am looking into the configuration/package you suggested.

Also, I didn't see anywhere in the Plank documentation about any of this either.

@sgtcoder
Copy link
Author

sgtcoder commented Apr 9, 2024

Installing that package throws a new error

Illuminate\Container\EntryNotFoundException 

Intervention\Image\ImageManager

The app bind suggestion also doesn't work on Laravel 11, and v3 removes Laravel support without the laravel package.

@frasmage
Copy link
Collaborator

frasmage commented Apr 9, 2024

Released 6.1.0 which will attempt to automatically pick a driver while still allowing it to be configured using intervention/image-laravel.

@sgtcoder
Copy link
Author

sgtcoder commented Apr 9, 2024

OMG, thank you! I ran the composer update and it finally installed successfully and ran the package:discover script.

@frasmage
Copy link
Collaborator

frasmage commented Apr 9, 2024

glad it worked! Apologies for the back and forth on this. There was a bit of a chicken and egg situation in the bootstrapping order that I wasn't aware of

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants