Laravel 上传图片并调整大小到 Digital Ocean Spaces
Laravel Upload Image and Resize to Digital Ocean Spaces
我尝试上传图片并调整大小到数字海洋空间,但调整大小图片代码没有调整大小
$image = $request->file('image');
/**
* save resize image
*/
$thumb_uploads = env('CLOUD_POSTS_IMAGE_THUMB');
$image_resize = Image::make($image->getRealPath());
$image_resize->resize(50, 50, function ($constraint) {
$constraint->aspectRatio();
})->save(Storage::disk('spaces')->put($thumb_uploads .'/'.$image->hashName(), file_get_contents($image), 'public'));
试试这个,你应该使用调整大小的图像内容。
$image_resize = $image_resize->resize(50, 50, function ($constraint) {
$constraint->aspectRatio();
})->encode('jpg');
Storage::disk('spaces')->put($thumb_uploads .'/'.$image->hashName(), (string) $image_resize);
我尝试上传图片并调整大小到数字海洋空间,但调整大小图片代码没有调整大小
$image = $request->file('image');
/**
* save resize image
*/
$thumb_uploads = env('CLOUD_POSTS_IMAGE_THUMB');
$image_resize = Image::make($image->getRealPath());
$image_resize->resize(50, 50, function ($constraint) {
$constraint->aspectRatio();
})->save(Storage::disk('spaces')->put($thumb_uploads .'/'.$image->hashName(), file_get_contents($image), 'public'));
试试这个,你应该使用调整大小的图像内容。
$image_resize = $image_resize->resize(50, 50, function ($constraint) {
$constraint->aspectRatio();
})->encode('jpg');
Storage::disk('spaces')->put($thumb_uploads .'/'.$image->hashName(), (string) $image_resize);