helly Tue Jun 25 17:29:21 2002 EDT Added files: /phpdoc/en/reference/image/functions image_type_to_mime_type.xml
Modified files: /phpdoc/en/reference/image/functions getimagesize.xml Log: changes for getimagesize and new function #Q: how do i add the new function-file? Index: phpdoc/en/reference/image/functions/getimagesize.xml diff -u phpdoc/en/reference/image/functions/getimagesize.xml:1.3 phpdoc/en/reference/image/functions/getimagesize.xml:1.4 --- phpdoc/en/reference/image/functions/getimagesize.xml:1.3 Tue Jun 25 16:58:31 2002 +++ phpdoc/en/reference/image/functions/getimagesize.xml Tue Jun 25 17:29:20 +2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.3 $ --> +<!-- $Revision: 1.4 $ --> <!-- splitted from ./en/functions/image.xml, last change in rev 1.36 --> <refentry id="function.getimagesize"> <refnamediv> @@ -16,22 +16,24 @@ <para> The <function>getimagesize</function> function will determine the size of any <acronym>GIF</acronym>, <acronym>JPG</acronym>, - <acronym>PNG</acronym>, <acronym>SWF</acronym>, - <acronym>PSD</acronym>, <acronym>TIFF</acronym>, - or <acronym>BMP</acronym> image file and - return the dimensions along with the file type and a height/width - text string to be used inside a normal <acronym>HTML</acronym> - <literal>IMG</literal> tag. + <acronym>PNG</acronym>, <acronym>SWF</acronym>, + <acronym>SWC</acronym>, <acronym>PSD</acronym>, + <acronym>TIFF</acronym>, <acronym>BMP</acronym> or + <acronym>IFF</acronym> + image file and return the dimensions along with the file type and + a height/width text string to be used inside a normal + <acronym>HTML</acronym> <literal>IMG</literal> tag. </para> <para> Returns an array with 4 elements. Index 0 contains the width of the image in pixels. Index 1 contains the height. Index 2 a flag indicating the type of the image. 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. - Index 3 is a text string with the correct - height="yyy" width="xxx" string that can be used directly in an IMG - tag. + 8 = TIFF(motorola byte order, 9 = JPC, 10 = JP2, 11 = JPX, 12 = + JB2, 13 = SWC, 14 = IFF. These values correspond to the IMAGETYPE + constants taht were added in PHP 4.3. Index 3 is a text string with + the correct height="yyy" width="xxx" string that can be used + directly in an IMG tag. <example> <title>getimagesize (file)</title> <programlisting role="php"> @@ -55,12 +57,47 @@ </example> </para> <para> - With <acronym>JPG</acronym> images, two extras index are returned: - <literal>channel</literal> and <literal>bits</literal>. - <literal>channel</literal> will be 3 for RGB pictures, and 4 for CMYK + With <acronym>JPG</acronym> images, two extras index are returned : + <literal>channels</literal> and <literal>bits</literal>. + <literal>channels</literal> will be 3 for RGB pictures, and 4 for CMYK pictures. <literal>bits</literal> is the number of bits for each color. </para> <para> + Since PHP 4.3 <literal>bits</literal> and <literal>channels</literal> + are present for other image types, too. But these values or there + presence can be a bit confusing. As example <acronym>GIF<acronym> + allways uses 3 channels per pixel but the number of bits per pixel + cannot be computed for an animated <acronym>GIF<acronym> with a global + colortable. + </para> + <para> + Some formats may contain no image or multiple images. In such cases + GetImageSize might not be able to determine the size and returns zero + for width and height. + </para> + <para> + Since PHP 4.3 GetImageSize() does also return the additional + <literal>mime</literal> that receives the mime-type ot the image. + This information can be used to deliver images with correct http + Content-type header if this is unknown: + <example> + <title>getimagesize and mime-type</title> + <programlisting role="php"> +<![CDATA[ +<?php +$size = getimagesize ($filename); +$fp=fopen($filename, "rb"); +if ($size && $fp) { + header("Content-type: {$size['mime']}"); + fpassthru($fp); + exit; +} else // error +?> +]]> + </programlisting> + </example> + </para> + <para> If accessing the <parameter>filename</parameter> image is impossible, or if it isn't a valid picture, <function>getimagesize</function> will return &null; and generate a warning. @@ -99,7 +136,8 @@ This function does not require the GD image library. </simpara> <simpara> - See also <function>exif_imagetype</function>, <function>exif_read_data</function> + See also <function>image_type_to_mime_type</function>, + <function>exif_imagetype</function>, <function>exif_read_data</function> and <function>exif_thumbnail</function>. </simpara> <simpara> Index: phpdoc/en/reference/image/functions/image_type_to_mime_type.xml +++ phpdoc/en/reference/image/functions/image_type_to_mime_type.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <!-- splitted from ./en/functions/image.xml, last change in rev 1.36 --> <refentry id="function.image_type_to_mime_type"> <refnamediv> <refname>image_type_to_mime_type</refname> <refpurpose>Get Mime-Type for image-type returned by getimagesize, exif_read_data, exif_thumbnail, exif_imagetype</refpurpose> </refnamediv> <refsect1> <title>Description</title> <methodsynopsis> <type>string </type><methodname>image_type_to_mime_type</methodname> <methodparam><type>int</type><parameter>imagetype</parameter></methodparam> </methodsynopsis> <para> The <function>image_type_to_mime_type</function> function will determine the Mime-Type for an IMAGETYPE constant. <example> <title>image_type_to_mime_type (file)</title> <programlisting role="php"> <![CDATA[ <?php header ("Content-type: ".image_type_to_mime_type (IMAGETYPE_PNG)); ?> ]]> </programlisting> </example> </para> <para> <note> <simpara> This function does not require the GD image library. </simpara> <simpara> See also <function>getimagesize</function>, <function>exif_imagetype</function>, <function>exif_read_data</function> and <function>exif_thumbnail</function>. </simpara> </note> </para> </refsect1> </refentry> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> -- PHP Documentation Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php