php - Get the height of a image no matter what mime type -


i not need resize image, trying accomplish gathering actual height of $img browser interpret it. allow user upload image reason images won't return dimensions, getimagesize();

$img = $_get['img'];   unction remoteimage($url){ $ch = curl_init ($url); curl_setopt($ch, curlopt_header, 0); curl_setopt($ch, curlopt_returntransfer, 1); curl_setopt($ch, curlopt_binarytransfer,1); curl_setopt($ch, curlopt_range, "0-10240");  $fn = $img; $raw = curl_exec($ch); $result = array();  if(file_exists($fn)){     unlink($fn); }  if ($raw !== false) {      $status = curl_getinfo($ch, curlinfo_http_code);      if ($status == 200 || $status == 206) {          $result["w"] = 0;         $result["h"] = 0;          $fp = fopen($fn, 'x');         fwrite($fp, $raw);         fclose($fp);          $size = getimagesize($fn);          if ($size===false) {         //  cannot file size information         } else {         //  return width , height             list($result["w"], $result["h"]) = $size;         }      } }  curl_close ($ch);  return $result; }  $outputheight = $result["h"]; 

updated : can use php function imagesy() height of image resource. method needs image resource not path.you have this:it should work type of images

$x="resultproces.gif"; $im = imagecreatefromstring(file_get_contents($x)); echo imagesy($im); 

see manuals here:http://php.net/manual/en/function.imagesy.php http://php.net/manual/en/function.imagecreatefromstring.php


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -