Laravel 5.4 Invention Image Not Readable 当图像可读时异常
Laravel 5.4 Intevention Image Not Readable Exception when the image is readable
我正在使用 Laravel 5.4 了解 Intervention Image 包。我的 public/images 文件夹中存储了一张图片。
我根据 Intervention 页面上的说明安装了 Image:对我的 composer.json 文件添加了干预,运行 作曲家更新,更新了我的 config/app 文件,以及 运行作曲家转储自动加载。
直接作为图片访问时(代码中的printf语句
下面的块)图像显示。
使用 make 方法,我在
AbstractDecoder.php.
有没有人看到我的代码是否有问题或者可能错过了安装步骤?
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Intervention\Image\Facades\Image;
class TestController extends Controller
{
public function imagetest()
{
printf('<img src="/images/j6.jpg">'); //correctly displays image on page
$img = Image::make("/images/j6.jpg")->resize(300, 200); //throws the error
return $img->response('jpg');
}
}
这是页面上 "printf" 图片之后的错误块的开头:
Whoops, looks like something went wrong.
1/1
NotReadableException in AbstractDecoder.php line 339:
Image source not readable
in AbstractDecoder.php line 339
at AbstractDecoder->init('/images/j6.jpg') in AbstractDriver.php line 64
at AbstractDriver->init('/images/j6.jpg') in ImageManager.php line 50
at ImageManager->make('/images/j6.jpg') in Facade.php line 221
at Facade::__callStatic('make', array('/images/j6.jpg')) in TestController.php line 14
at TestController->imagetest()
at call_user_func_array(array(object(TestController), 'imagetest'), array()) in Controller.php line 55
at Controller->callAction('imagetest', array()) in ControllerDispatcher.php line 44
at ControllerDispatcher->dispatch(object(Route), object(TestController), 'imagetest') in Route.php line 203
at Route->runController() in Route.php line 160
at Route->run() in Router.php line 559
at Router->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 30
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in SubstituteBindings.php line 41
at SubstituteBindings->handle(object(Request), object(Closure)) in Pipeline.php line 148
您需要在图像标签中的 filesystem.Judging 中提供图像文件的完整路径,该图像应位于您的 webroot 中的 images
文件夹中。你可以做到这一点。
$imagePath = public_path('images/j6.jpg');
$img = Image::make($imagePath)->resize(300, 200);
我正在使用 Laravel 5.4 了解 Intervention Image 包。我的 public/images 文件夹中存储了一张图片。
我根据 Intervention 页面上的说明安装了 Image:对我的 composer.json 文件添加了干预,运行 作曲家更新,更新了我的 config/app 文件,以及 运行作曲家转储自动加载。
直接作为图片访问时(代码中的printf语句 下面的块)图像显示。
使用 make 方法,我在 AbstractDecoder.php.
有没有人看到我的代码是否有问题或者可能错过了安装步骤?
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Intervention\Image\Facades\Image;
class TestController extends Controller
{
public function imagetest()
{
printf('<img src="/images/j6.jpg">'); //correctly displays image on page
$img = Image::make("/images/j6.jpg")->resize(300, 200); //throws the error
return $img->response('jpg');
}
}
这是页面上 "printf" 图片之后的错误块的开头:
Whoops, looks like something went wrong.
1/1
NotReadableException in AbstractDecoder.php line 339:
Image source not readable
in AbstractDecoder.php line 339
at AbstractDecoder->init('/images/j6.jpg') in AbstractDriver.php line 64
at AbstractDriver->init('/images/j6.jpg') in ImageManager.php line 50
at ImageManager->make('/images/j6.jpg') in Facade.php line 221
at Facade::__callStatic('make', array('/images/j6.jpg')) in TestController.php line 14
at TestController->imagetest()
at call_user_func_array(array(object(TestController), 'imagetest'), array()) in Controller.php line 55
at Controller->callAction('imagetest', array()) in ControllerDispatcher.php line 44
at ControllerDispatcher->dispatch(object(Route), object(TestController), 'imagetest') in Route.php line 203
at Route->runController() in Route.php line 160
at Route->run() in Router.php line 559
at Router->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 30
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in SubstituteBindings.php line 41
at SubstituteBindings->handle(object(Request), object(Closure)) in Pipeline.php line 148
您需要在图像标签中的 filesystem.Judging 中提供图像文件的完整路径,该图像应位于您的 webroot 中的 images
文件夹中。你可以做到这一点。
$imagePath = public_path('images/j6.jpg');
$img = Image::make($imagePath)->resize(300, 200);