phplaravel-5intervention

Unable to init from given url in intervention/image": "^2.3


I want to save the images from google plus as below url it is work as well in local computer but I got below error when upload to ubuntu14.

$image = Image::make('https://lh6.googleusercontent.com/-Gcp_Wjj7yA0/AAAAAAAAAAI/AAAAAAAAAB8/hl1xcz4FnEI/photo.jpg')
            ->resize(100, 100)->save(public_path('image/userface/fuck.jpg'));

Errors

Unable to init from given url

Solution

  • I have found a workaround for this problem. When we re-fetch the image, 99% it works, so i modified saving function to try to save for 3 times if it fails even then, we abort.

    Solution

        $flag = true;
        $try = 1;
        while ($flag && $try <= 3):
            try {
                Image::make($path)->save(public_path("{$public_app_path}/" . $filename));
                //Image migrated successfully
                $flag = false;
            } catch (\Exception $e) {
                //not throwing  error when exception occurs
            }
            $try++;
        endwhile;