getp_w_picpathsize -- Get the size of an p_w_picpath
Description
array getp_w_picpathsize ( string filename [, array &p_w_picpathinfo] )The getp_w_picpathsize() function will determine the size of any GIF, JPG, PNG, SWF, SWC, PSD, TIFF, BMP, IFF,JP2, JPX, JB2, JPC, XBM, or WBMP p_w_picpath file and return the dimensions along with the file type and a height/width text string to be used inside a normal HTML <IMG> tag.
If accessing the filename p_w_picpath is impossible, or if it isn't a valid picture, getp_w_picpathsize() will return FALSE and generate an error of level E_WARNING.
Note: Support for JPC, JP2, JPX, JB2, XBM, and WBMP became available in PHP 4.3.2. Support for SWC exists as of PHP 4.3.0 and TIFF support was added in PHP 4.2.0
Note: JPEG 2000 support was added in PHP 4.3.2. Note that JPC and JP2 are capable of having components with different bit depths. In this case, the value for "bits" is the highest bit depth encountered. Also, JP2 files may contain multiple JPEG 2000 codestreams. In this case, getp_w_picpathsize() returns the values for the first codestream it encounters in the root of the file.
Note: The getp_w_picpathsize() function does not require the GD p_w_picpath library.
Returns an array with 4 elements. Index 0 contains the width of the p_w_picpath in pixels. Index 1 contains the height. Index 2 is a flag indicating the type of the p_w_picpath: 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 values correspond to the IMAGETYPE constants that were added in PHP 4.3.0. Index 3 is a text string with the correct height="yyy" width="xxx" string that can be used directly in an IMG tag.
URL support was added in PHP 4.0.5
With JPG p_w_picpaths, two extra indexes are returned: channels and bits. channels will be 3 for RGB pictures and 4 for CMYK pictures. bits is the number of bits for each color.
Beginning with PHP 4.3.0, bits and channels are present for other p_w_picpath types, too. However, the presence of these values can be a bit confusing. As an example, GIF always uses 3 channels per pixel, but the number of bits per pixel cannot be calculated for an animated GIF with a global color table.
Some formats may contain no p_w_picpath or may contain multiple p_w_picpaths. In these cases, getp_w_picpathsize() might not be able to properly determine the p_w_picpath size. getp_w_picpathsize() will return zero for width and height in these cases.
Beginning with PHP 4.3.0, getp_w_picpathsize() also returns an additional parameter, mime, that corresponds with the MIME type of the p_w_picpath. This information can be used to deliver p_w_picpaths with correct HTTP Content-type headers:
The optional p_w_picpathinfo parameter allows you to extract some extended information from the p_w_picpath 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 p_w_picpaths. 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.
转载于:https://blog.51cto.com/tiandinanyu/808816