Home >Backend Development >PHP Tutorial >php getimagesize_PHP tutorial

php getimagesize_PHP tutorial

WBOY
WBOYOriginal
2016-07-20 11:06:36953browse

php getimagesize

getimagesize reads image-related information and returns an array with four cells. Index 0 contains the pixel values ​​for the width of the image, and index 1 contains the pixel values ​​for the height of the image. Index 2 is the index of the image type

$size = getimagesize($filename);
$fp = fopen($filename, "rb");
if ( $size && $fp) {
header("Content-type: {$size['mime']}");
fpassthru($fp);
exit;
} else {
// error
}
?>


#2 getimagesize() example

list($width, $height , $type, $attr) = getimagesize("img/flag.jpg");
echo "getimagesize() example" ;
?>

Example #3 getimagesize (URL)

$size = getimagesize("http://www.example.com/gifs /logo.gif");
$size = getimagesize("http://www.example.com/gifs/lo%20go.gif");
?>

Example # 4 getimagesize() returning IPTC

$size = getimagesize("testimg.jpg", $info);
if (isset($info["APP13"])) {
$iptc = iptcparse($info["APP13"]);
var_dump($iptc);
}
?>


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/445015.htmlTechArticlephp getimagesize getimagesize reads image related information and returns an array with four cells. Index 0 contains the pixel value of the image width, index 1 contains the pixel value of the image height...
Statement:
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