Home  >  Article  >  Backend Development  >  The function getimagesize obtains the length and width of the image and other information

The function getimagesize obtains the length and width of the image and other information

WBOY
WBOYOriginal
2016-07-25 09:01:50927browse
The function getimagesize 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.
Index 2 is the tag of the 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.
These tags correspond to the IMAGETYPE constant added in PHP 4.3.0. Index 3 is a text string with the content "height="yyy" width="xxx"" and can be used directly in the IMG tag.
PHP official website manual
  1. $images_array = array("http://static.zend.com/img/logo.gif");
  2. foreach($images_array as $image){
  3. list($width, $height, $type, $attr) = getimagesize($image);
  4. $new_height = (int)(192 / $width * $height);
  5. echo '
  6. ';
  7. }
Copy code


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