GD library |check image width, height,type ||PHP
1.Attributes in list
test.php
<?php
list($width, $height, $type, $attr) = getimagesize("1.png");//open as file
echo $width." ".$height." ".$type." ".$attr;
?>
Output
1365 603 3 width="1365" height="603"
OR
code.php
$size_info1 = getimagesize($img);
print_r($size_info1);echo "<br/>";
Output
Array ( [0] => 200 [1] => 200 [2] => 3 [3] => width="200" height="200" [bits] => 8 [mime] => image/png )
OR open as string
Code.php
$data = file_get_contents($img);
print_r($data);echo "<br/>";
Output: output string of image
?PNG IHDR???X?? pHYs??9iCCPPhotoshop ICC profilex???J?P??EšV??p'QPl???I[?
......
OR get data from string
code.php
$img = 'stamp.png';
$data = file_get_contents($img);
$size_info2 = getimagesizefromstring($data);
print_r($size_info2);echo "<br/>";
Output
Array ( [0] => 200 [1] => 200 [2] => 3 [3] => width="200" height="200" [bits] => 8 [mime] => image/png )
OR Width & Height
$img = imagecreatefrompng('stamp.png');
echo imagesx($img); //size of image x axis
echo imagesy($img); //size of image x axis
200 200