php get image width and height

getimagesize()To get the width and height of an image, you can use functions in PHP . This function accepts the path of an image file as a parameter and returns an array containing the width and height information of the image.

<?php
// 图片文件路径
$imagePath = 'path/to/your/image.jpg';

// 获取图片尺寸信息
$imageInfo = getimagesize($imagePath);

// 提取宽度和高度
$width = $imageInfo[0];
$height = $imageInfo[1];

// 输出宽度和高度
echo "宽度: " . $width . "px<br>";
echo "高度: " . $height . "px";
?>

Replace 'path/to/your/image.jpg'it with your actual image path, then run this code, you will get the width and height information of the image.

Guess you like

Origin blog.csdn.net/qq_39339179/article/details/131191394