3 months ago

resizing an avatar from FB using socialite/intervention

Posted 3 months ago by Lazlothemonkey

I am trying to resize a Facebook avatar I get from Socialite and then save it to s3:

if ($data['profile_pic']) {

                    $profile_pic = file_get_contents($data['profile_pic']);
                    $filename = md5(time()).'_social_profile_pic_original.jpg';

                    //error starts from here

                    $resizedImg = Image::make($profile_pic)->fit(500, 500);
                    $path = 'user/'.$newUser->id.'/profile_pic/'.$filename;

                    Storage::disk('s3')->put($path, (string)$resizedImg, 'public');
                    $url = Storage::disk('s3')->url($path);

                    $imageArray = ['profile_pic' => $url];

However the image is not resizing it correctly. If I leave out the resizing part, the original image gets saved to s3 without problems. But when I try to resize it, the image doesn't show anymore...

Could you anyone give me a clue as to why it's not working? thanks

Please sign in or create an account to participate in this conversation.