最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Intervention Image and Laravel 11 - Stack Overflow

programmeradmin1浏览0评论

I am having a problem with intervention image and Laravel 11. I am upgrading a program which is fine with Laravel 10.

I installed with

composer require intervention/image-laravel

and then ran

php artisan vendor:publish --provider="Intervention\Image\Laravel\ServiceProvider"

I have also installed Unisharp's filemanager and I notice that the composer.json file has these two entries

"intervention/image": "^3.11",
"intervention/image-laravel": "^1.5",

I have a function to resize which includes

if (!file_exists($image2)) {
        //200 wide
        if (file_exists($image)) {
            $destinationPath = $path2;
            $imgsave2 = $destinationPath . '/' . $img;
            $img2 = Image::read($image);
            $img2
                ->resize(200, null, function ($constraint) {
                    $constraint->aspectRatio();
                })
                ->save($imgsave2);
        }
    }

(This simply takes in the image as image2 and the destination path and places it in a subdirectory based on the image size, hence the destination path). This function has

use Intervention\Image\Laravel\Facades\Image;

at the top

When I first tried to use this I had am image that it could not find Image so I setup a facade as

class AliasServiceProvider extends ServiceProvider
{
    /**
     * Register services.
     */
    public function register(): void
    {
        $loader = AliasLoader::getInstance();
        $loader->alias('Image',  Intervention\Image\Laravel\Facades\Image::class);
    }

    /**
     * Bootstrap services.
     */
    public function boot(): void
    {
        //
    }

Also in the providers in the bootstrap directory I have:

App\Providers\AliasServiceProvider::class,

Now when I try to use it I am getting an error

Unable to resolve driver. Argument must be either an instance of Intervention\Image\Interfaces\DriverInterface::class or a qualified namespaced name of the driver class.

I am going around and around with this any help would be very greatly appreciated.

发布评论

评论列表(0)

  1. 暂无评论