Php 计算图像高度&;快速宽度

Php 计算图像高度&;快速宽度,php,image,Php,Image,我有以下程序来快速计算图像的高度和宽度,如compare getImageSize();PHP函数。原因是什么?远程图像需要下载到您的服务器中,然后由php在本地读取 <?php function getimagesize($image_url){ $handle = fopen ($image_url, "rb"); $contents = ""; if ($handle) { do {

我有以下程序来快速计算图像的高度和宽度,如compare getImageSize();PHP函数。原因是什么?远程图像需要下载到您的服务器中,然后由php在本地读取

<?php
   function getimagesize($image_url){
    $handle = fopen ($image_url, "rb");
    $contents = ""; 
            if ($handle) {
                do {
                    $count += 1;
                    $data = fread($handle, 8192);
                        if (strlen($data) == 0) {
                            break;
                       }   
                $contents .= $data;
                } while(true);
            } else { return false; }
    fclose ($handle);

    $im = ImageCreateFromString($contents);
    if (!$im) { return false; }
    $gis[0] = ImageSX($im);
    $gis[1] = ImageSY($im);
    // array member 3 is used below to keep with current getimagesize standards
    $gis[3] = "width={$gis[0]} height={$gis[1]}";
    ImageDestroy($im);
    return $gis;                                                                                                                                                       
   }   
$image_url = "http://xample.com/4.jpg";
$get = getimagesize($image_url);
print $get;

?>

PHP中已经有一个名为getImageSize的标准方法。重命名你的方法,一切都很好


您可以使用php中的标准方法getimagesize()


请阅读问题,我已经给出了我不能使用getimagesize的原因。
Fatal error: Cannot redeclare getimagesize() in C:\wamp\www\test\CheckWH.php on line 25
list($width, $height) = getimagesize("http://xample.com/4.jpg"); 
echo "$width x $height (px)";