duannuan0074 2015-11-05 21:33
浏览 39

Laravel 4.2干预 - 图像显示破碎的图像

I am following the Laracast tutorial for handling image manipulation using Intervention. After adding it to my composer file and running composer update, I added it to my service providers and aliases as instructed in the installation guide. Also, I'm using Vagrant 1.7.4 and a Laravel virtual box called, Scotch Box 2.5.

However, I have not been able to successfully use Intervention in my app. Here is my sample route:

Route::get('foo', function() {
    $image = Image::make('http://placehold.it/500x500/000/e8117f');
    return Response::make($image->encode('jpg'), 200, ['Content-Type' => 'image/jpeg']);
});

When I visit the page in the browser, all I see is a broken image icon. And I'm really confused as to why the developer inspector tool in Chrome displays:

<img style="-webkit-user-select: none" src="http://192.168.33.10/public/foo">
  • 写回答

1条回答 默认 最新

  • dongxiong4571 2015-11-05 21:51
    关注

    Instead of returning Response::make, you can just do this:

    return $image->response('jpg');
    

    You can also do this:

    return $image->response();
    

    By default the response data will be encoded in the type of the current image. If no image type is defined yet, method will return jpeg encoded data.

    Source: http://image.intervention.io/api/response

    评论

报告相同问题?

悬赏问题

  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 linux驱动,linux应用,多线程