Laravel 使用 intervention image 包上传、剪裁图片

本文介绍如何在Laravel项目中使用Intervention Image库进行图片处理,包括安装配置、使用上传的文件创建图片实例及调整尺寸等操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  1. 通过 composer 安装 composer intervention/image
  2. 修改 config/app.php 文件,添加 $providers$aliases
    ‘Intervention\Image\ImageServiceProvider’
    ‘Image’ => ‘Intervention\Image\Facades\Image’
  3. By default Intervention Image uses PHP’s GD library extension to process all images. If you want to switch to Imagick, you can pull a configuration file into your application by running on of the following artisan command.
Publish configuration in Laravel 5

$ php artisan vendor:publish --provider=“Intervention\Image\ImageServiceProviderLaravel5”

Handling image uploads in Laravel

In a Laravel application it is also possible to pass an uploaded file directly to the make method.

Creating Image from File Upload in Laravel
// resizing an uploaded file
Image::make(Input::file('photo'))->resize(300, 200)->save('foo.jpg');

参考资料

ORM-based file upload package for php. http://codesleeve.com https://github.com/CodeSleeve/stapler

在Laravel项目中实现Ajax上传用户头像

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值