我如何在 Laravel 框架中获取图像的宽度和高度?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/45563291/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 16:28:04 来源:igfitidea点击:
How i get width and height of a image in Laravel Framework?
提问by ThomasPham
In this image,
在这张图片中,
I can get the width
and height
of the image in the directory.
我可以在目录中获取图像的width
和height
。
But i want to get the width and height of a picture before i upload the image.
但我想在上传图片之前获取图片的宽度和高度。
How can i achieve this?
我怎样才能做到这一点?
回答by Kuldeep Mishra
$data = getimagesize($filename);
$width = $data[0];
$height = $data[1];
回答by Daud khan
Through Intervention Image you can do it as
通过干预图像,您可以这样做
$upload_file = $request->file('gallery_image');
$height = Image::make($upload_file)->height();
$width = Image::make($upload_file)->width();
回答by Aan Faisal
You can use
您可以使用
<?php
$imagedetails = getimagesize($_FILES['file-vi']['tmp_name']);
$width = $imagedetails[0];
$height = $imagedetails[1];
?>