PHP Get picture size (width, height) _php tutorial

Source: Internet
Author: User
This article mainly explains PHP to obtain the image size (width, height) function, namely the getimagesize () function.

Syntax: array getimagesize (string filename [, array &imageinfo])

Function: the getimagesize () function will determine any GIF,JPG,PNG,SWF,SWC,PSD,TIFF,BMP,IFF,JP2,JPX,JB2,JPC,XBM or wbmp image file and return the file size, size, A file type and a height/width text string that can be used in markup in a normal HTML file. If the specified image cannot be accessed or is not a valid image, GetImageSize () returns false and produces a e_warning level error.

Note:

(1) This function does not require GD Image library support.

(2) The function can be used to obtain the remote data in addition to the local image or flash information.

Example:

 
  "; echo" Image height ". $height; echo"
"; echo" Image type ". $type; echo"
"Echo" Attribute ". $attr;

The output information is as follows:

Image width 200

Image Height 55

Image Type 1

Image attribute width= "55" height= "

The parameters of the picture type are as follows:

1 = GIF 5 = PSD 9 = JPC = SWC

2 = JPG 6 = BMP = JP2 = IFF

3 = PNG 7 = TIFF (Intel byte order) one = JPX = WBMP

4 = SWF 8 = TIFF (motorola byte order) = JB2 = XBM

Articles you may be interested in

    • PHP Gets the client computer screen width, height, resolution method
    • A way for JavaScript to get the width and height of a picture
    • JS Address bar effect (displays the size of all linked images within the page and the height of the current browser)
    • Powerful PHP Image processing class (watermark, transparency, zoom, sharpen, rotate, flip, cut, invert)
    • PHP get remote picture and download save to local
    • Text area textarea box based on input self-adapting height
    • How PHP can turn on compressed output to website to enhance website access speed
    • JS determines whether the picture is loaded and gets the width of the image

http://www.bkjia.com/PHPjc/764094.html www.bkjia.com true http://www.bkjia.com/PHPjc/764094.html techarticle This article mainly explains PHP to obtain the image size (width, height) function, namely the getimagesize () function. Syntax: array getimagesize (string filename [, array imageinfo]) function: ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.