mrkarma4ya's avatar

Image Intervention not doing anything

I installed the intervention package, and I get no errors at all. But the image is unmodified. Here's my code:


use Intervention\Image\Facades\Image;

...

if ($request->hasFile('avatar')) {
            $avatar = ($this->generateImageFileName($request->file('avatar'), 'users'));
            $request->file('avatar')->storeAs('public', $avatar); //Upload Avatar
            //dd($avatar);
            Image::make('storage/'.$avatar)->fit(600); //resize to 600x600
            $user->avatar = $avatar; //Write to DB
        }

If I dump the Image::make line, I get this:

  #driver: Intervention\Image\Gd\Driver {#334 ▼
    +decoder: Intervention\Image\Gd\Decoder {#335 ▼
      -data: null
    }
    +encoder: Intervention\Image\Gd\Encoder {#336 ▼
      +result: null
      +image: null
      +format: null
      +quality: null
    }
  }
  #core: gd resource @509 ▼
    size: "600x600"
    trueColor: true
  }
  #backups: []
  +encoded: ""
  +mime: "image/png"
  +dirname: "storage/img/users"
  +basename: "BloodBorne-Dark-Souls-фэндомы-cleric-beast-5224478_95e0bfc9539c0ae8cbcf49017a14d9e5dc4db24e.png"
  +extension: "png"
  +filename: "BloodBorne-Dark-Souls-фэндомы-cleric-beast-5224478_95e0bfc9539c0ae8cbcf49017a14d9e5dc4db24e"
}

To install, I ran composer require intervention/image, added the service provider and facade alias as mentioned in the docs and ran composer install, just to be sure. Is there something I'm missing?

0 likes
2 replies
mrkarma4ya's avatar
mrkarma4ya
OP
Best Answer
Level 3

Windows, Laragon.

Actually, I found the issue, turns out I had to manually save it.

Doing this worked:

$resizedAvatar = Image::make('storage/'.$avatar)->fit(600); //resize to 600x600
$resizedAvatar->save();

Please or to participate in this conversation.