我有一个关于给定图像的大小调整过程的小问题,我正在尝试提交包含输入类型的表单 - >文件< - 我能够上传图片而不调整大小,之后我决定调整大小图像所以我使用以下方法安装了干预图像库:
composer require intervention/image
Run Code Online (Sandbox Code Playgroud)
然后我将库集成到我的Laravel框架中
Intervention\Image\ImageServiceProvider::class
'Image' => Intervention\Image\Facades\Image::class
Run Code Online (Sandbox Code Playgroud)
最后我配置如下
php artisan vendor:publish --provider="Intervention\Image\ImageServiceProviderLaravel5"
Run Code Online (Sandbox Code Playgroud)
我的控制器如下
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Input;
use Image;
class ProjectController extends Controller{
public function project(Request $request){
$file = Input::file('file');
$fileName = time().'-'.$file->getClientOriginalName();
$file -> move('uploads', $fileName);
$img=Image::make('public/uploads/', $file->getRealPath())->resize(320, 240)->save('public/uploads/',$file->getClientOriginalName());
}
}
Run Code Online (Sandbox Code Playgroud)
但不是调整图片大小,而是抛出以下异常
NotReadableException in AbstractDecoder.php line 302:
Image source not readable
Run Code Online (Sandbox Code Playgroud)