laravel get image size code example

Example 1: get image width and height in laravel

Core php :
list($width, $height, $type, $attr) = getimagesize($_FILES["gallery_image"]['tmp_name']);

With Intervention :
$upload_file = $request->file('gallery_image');
$height = Image::make($upload_file)->height();
$width = Image::make($upload_file)->width();

Example 2: how get the Photo size upload in laravel

$request->file('image')->getSize()

Example 3: how get the size of image in laravel

$image = getimagesize($request->image);
        $width = $image[0];
        $height = $image[1];

Example 4: how get the photo size upload in laravel

request()->validate([
            'image' => 'image|mimes:jpeg,png,jpg|max:2048',
        ]);

Tags:

Php Example