Home > Backend Development > PHP Tutorial > Specific usage of PHP function getimagesize_PHP tutorial

Specific usage of PHP function getimagesize_PHP tutorial

WBOY
Release: 2016-07-15 13:33:27
Original
1589 people have browsed it

Definition

Get the length and width of the image.

Syntax:

array getimagesize(string filename, array [imageinfo]);

Return value:

Array

Function type:

Graphics processing

Content description:

PHP function getimagesize can be used to get the height and width of gif, jpeg and png images on www. You can use this function without installing gd library. The returned array has four elements. The first element of the returned array (index value 0) is the height of the image, in pixels.

The second element (index 1) is the width of the image. The third element (index value 2) is the file format of the image, with a value of 1 for gif format, 2 for jpeg/jpg format, and 3 for png format. The fourth element (index value 3) is the height and width string of the image, height=xxx width=yyy.

The omitted parameter imageinfo is used to obtain some image-related information, such as the app13 tag of iptc (http://www.xe.net/iptc), which can be added to the image. You can use iptcparse( ) to parse.

Code example of PHP function getimagesize:

<ol class="dp-xml">
<li class="alt"><span><span class="tag"><</span><span> ?php  </span></span></li><li><span>function myimg($imgfile) {  </span></li><li class="alt"><span>$</span><span class="attribute">size</span><span> = </span><span class="attribute-value">getimagesize</span><span>($imgfile);  </span></li><li><span>echo "</span><span class="tag"><</span><span class="tag-name">img</span><span> </span><span class="attribute">src</span><span>="$imgfile" $size[3]</span><span class="tag">></span><span>";  </span></span></li>
<li class="alt"><span>}  </span></li>
<li><span>myimg("img/img1.gif");  </span></li>
<li class="alt"><span>myimg("img/img2.png");  </span></li>
<li>
<span class="tag">?></span><span> </span>
</li>
</ol>
Copy after login


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/446063.htmlTechArticleDefine the length and width of the image. Syntax: array getimagesize(string filename, array [imageinfo]); Return value: array Function type: Graphics processing Content description: PHP function getimagesize is available...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template