Home > Backend Development > PHP Tutorial > A function getImageInfo() that comprehensively obtains image information_PHP tutorial

A function getImageInfo() that comprehensively obtains image information_PHP tutorial

WBOY
Release: 2016-07-21 14:52:48
Original
766 people have browsed it

function getImageInfo($img) { //$img is the absolute path of the image file
$img_info = getimagesize($img);
switch ($img_info[2]) {
case 1:
$imgtype = "GIF";
break;
case 2:
$imgtype = "JPG";
break;
case 3:
$imgtype = "PNG";
break;
}
$img_type = $imgtype."image";
$img_size = ceil(filesize($img)/1000)."k"; //Get file size

$new_img_info = array (
"width"=>$img_info[0],
"height"=>$img_info[1],
"type"=>$img_type
"size"=>$img_size
}
return $new_img_info;
}
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/371519.htmlTechArticle?php function getImageInfo($img) { //$img is the absolute path of the image file $img_info = getimagesize( $img); switch ($img_info[2]) { case 1: $imgtype = GIF; break; case 2: $imgtype = JPG;...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template