Use GetImageSize function in ordert to get image size in php.
Syntax: array getimagesize ( string filename [, array &imageinfo] )
It returns
- image width
- image height
- image type; 1 = GIF, 2 = JPG, 3 = PNG, 4 = SWF, 5 = PSD, 6 = BMP, 7 = TIFF(intel byte order), 8 = TIFF(motorola byte order), 9 = JPC, 10 = JP2, 11 = JPX, 12 = JB2, 13 = SWC, 14 = IFF, 15 = WBMP, 16 = XBM
- image size string to use in html <img> tag (sample: height="100" width="50")
- some other image parameters, starting PHP 4.3.0
Cut from the php manual:
The optional imageinfo parameter allows you to extract some extended information from the image file. Currently, this will return the different JPG APP markers as an associative array. Some programs use these APP markers to embed text information in images. A very common one is to embed IPTC http://www.iptc.org/ information in the APP13 marker. You can use the iptcparse() function to parse the binary APP13 marker into something readable.
<?php
$size = GetImageSize("my-picture.jpg", $info);
if (isset($info["APP13"])) {
$iptc = iptcparse($info["APP13"]);
var_dump($iptc);
}
$img_x = $size[0];
$img_y = $size[1];
$img_type = $size[2];
$img_sizes = $size[3];
$channels = $size['channels'];
$bits = $size['bits'];
$mime = $size['mime']; // delivers correct HTTP Content-type to be user in headers
// sample: header("Content-type: {$size['mime']}");
?>