Microsoft Word - Core PHP Programming Using PHP to Build Dynamic Web Sites

(singke) #1

<?
//go from Windows gamma to Macintosh gamma
$color = gamma_correct_tag("#CC0000", 2.2, 1.571);


print("FONT COLOR=\"$color\">");
print("Sample Text");
print("/FONT>");
?>


array getimagesize(string filename, array image_info)


The getimagesize function returns a four-element array that tells you the image size of
the given filename. The contents of this array are listed in Table 12.1. The file must be a
graphic file in one of three formats: GIF, JPEG, or PNG.


The optional image_info argument will be set with additional information from the file.
At the time of this writing, this array is set with APP markers 0–15 from JPEG files. One
of the most common is APP13, which is an International Press Telecommunications
Council (IPTC) block. These blocks are used to communicate information about
electronic media released to news agencies. They are stored in binary form, so to decode
them you must use the iptcparse function. You can find out more about the IPTC at
their Web site: http://www.iptc.org/iptc/.


Table 12.1. Array Elements for getimagesize
Element Description
0 Width in pixels
1 Height in pixels
2 Image Type (GIF = 1, JPG = 2, PNG = 3)


3 String like "height=150 width=200", usable in IMG tag
bits Bits per sample for jpegs
channels Samples per pixel for jpegs


Note that the image_info argument must be passed by reference, which means it must be
preceded by an ampersand.


<?
$image_file = "php.jpg";
$image_size = getimagesize($image_file, &$image_info);
print("IMG SRC=\"$image_file\" $image_size[3]>BR>\n");


//show information if it exists
while(list($key, $value) = each($image_info))
{
print($key. "BR>\n");
}
?>

Free download pdf