【发布时间】:2017-05-29 17:31:23
【问题描述】:
我正在学习 Laravel 5.4 的干预图像包。我的公共/图像文件夹中存储了一张图像。
我根据干预页面上的说明安装了 Image:向我的 composer.json 文件添加干预,运行 composer update,更新我的配置/应用程序文件,并运行 composer dump-autoload。
当直接作为图片访问时(代码中的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
【问题讨论】:
-
如果你在 laravel 中使用 public_path 辅助函数会怎样。例如:$img = Image::make(public_path('images/j6.jpg'))->resize(300, 200);
标签: php laravel-5 intervention