【Laravel 5.1】 GD driver is only able to decode JPG, PNG, GIF or WebP files.

NotReadableException in Decoder.php line 59:
Unsupported image type. GD driver is only able to decode JPG, PNG, GIF or WebP files.

StackTrace

[1] in Decoder.php line 59
[2] at Decoder->initFromPath('/tmp/phpyMkwYg') in AbstractDecoder.php line 324
[3] at AbstractDecoder->init(object(UploadedFile)) in AbstractDriver.php line 66
[4] at AbstractDriver->init(object(UploadedFile)) in ImageManager.php line 54
[5] at ImageManager->make(object(UploadedFile)) in Facade.php line 215

Intervention/Image/AbstractDecoder.php

initFromPath('/tmp/phpyMkwYg')

            case $this->isSplFileInfo():
                return $this->initFromPath($this->data->getRealPath());
    public function initFromUrl($url)
    {
        
        $options = [
            'http' => [
                'method'=>"GET",
                'header'=>"Accept-language: en\r\n".
                "User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.2 (KHTML, like Gecko) Chrome/22.0.1216.0 Safari/537.2\r\n"
          ]
        ];
        
        $context  = stream_context_create($options);
        

        if ($data = @file_get_contents($url, false, $context)) {
            return $this->initFromBinary($data);
        }

        throw new NotReadableException(
            "Unable to init from given url (".$url.")."
        );
    }


at AbstractDriver->init(object(UploadedFile)) in ImageManager.php line 54

    public function make($data)
    {
        return $this->createDriver()->init($data);
    }


問題箇所発見

        $photo = $request->file('upload_image');
        $img = \Image::make($photo);
        $save_path = storage_path('app/');

\Image::make($photo);で問題発生。


driverをgdに設定している箇所

/vendor/intervention/image/src/config/config.php

``` <?php

return [

/*
|--------------------------------------------------------------------------
| Image Driver
|--------------------------------------------------------------------------
|
| Intervention Image supports "GD Library" and "Imagick" to process images
| internally. You may choose one of them according to your PHP
| configuration. By default PHP's "GD Library" implementation is used.
|
| Supported: "gd", "imagick"
|
*/

'driver' => 'gd'

];