PHP Get picture size (width, height)

Source: Internet
Author: User
Tags array file size string

This article mainly describes the PHP to get picture size (width, height) function, that is, 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, The file type and a height/width text string that can be used in the tag in a normal HTML file. If the specified image cannot be accessed or is not a valid image, GetImageSize () returns false and generates a e_warning level error.

Note:

(1) This function does not need the GD Image Library support.

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

Example:

<?php
list ($width, $height, $type, $attr) =getimagesize ("logo.gif");
echo "Image width". $width;
echo "<br/>";
echo "Image height". $height;
echo "<br/>";
echo "Image type". $type;
echo "<br/>";
echo "Attribute". $attr;

The output information is as follows:

Image width 200

Image Height 55

Image Type 1

Image attribute width= "height=" "55"

The parameters of the picture type are referenced 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 that you may be interested in

    • PHP access to the client computer screen width, height, resolution method
    • JS Address bar effects (display the size of all the linked pictures on the page and view the height of the current browser)
    • A way for JavaScript to get the width and height of a picture
    • Powerful PHP Image processing class (watermark, transparency, zoom, sharpen, rotate, flip, cut, invert color)
    • PHP Gets the remote picture and downloads it to the local
    • How PHP determines whether a GIF picture is a dynamic picture (animation)
    • Text area textarea box adapts height to input
    • Use PHP function memory_get_usage to get current PHP memory consumption to achieve program performance optimization


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.