search for in the  
<getimagesizeimage_type_to_mime_type>
Last updated: Thu, 19 May 2005

image_type_to_extension

(no version information, might be only in CVS)

image_type_to_extension --  Get file extension for image type

Description

string image_type_to_extension ( int imagetype [, bool include_dot] )

Warning

This function is currently not documented; only the argument list is available.



User Contributed Notes
image_type_to_extension
Golf at dds dot nl
24-Apr-2005 09:23
To get the "dot" part of this funtion working, one needs to change the following line from:

$dot = $include_dot ? $dot.'' : '';
to:
$dot = $include_dot ? $dot.'.' : '';

I also recommend to change the following line from:

function image_type_to_extension($imagetype,$include_dot=true)
to:
function image_type_to_extension($imagetype,$include_dot=false)

(This so that one gets a result without the dot by default, witch is nice when one needs to compair it later on)...
19-Apr-2005 07:11
Just an improvement/bugfix for the function below:
<?php
$dot
= $include_dot ? $dot.'' : '';
//surely what was meant is....:
$dot = $include_dot ? '.' : '';
?>

Because otherwise $dot always will be empty.....
mail at spybreak dot de
14-Aug-2004 08:12
In case your PHP doesn't have this function, you can use this:
<?

if(!function_exists('image_type_to_extension'))
{
   function
image_type_to_extension($imagetype,$include_dot=true)
   {
       if(empty(
$imagetype)) return false;
      
$dot = $include_dot ? $dot.'' : '';
       switch(
$imagetype)
       {
           case
IMAGETYPE_GIF    : return $dot.'gif';
           case
IMAGETYPE_JPEG    : return $dot.'jpg';
           case
IMAGETYPE_PNG    : return $dot.'png';
           case
IMAGETYPE_SWF    : return $dot.'swf';
           case
IMAGETYPE_PSD    : return $dot.'psd';
           case
IMAGETYPE_WBMP    : return $dot.'wbmp';
           case
IMAGETYPE_XBM    : return $dot.'xbm';
           case
IMAGETYPE_TIFF_II : return $dot.'tiff';
           case
IMAGETYPE_TIFF_MM : return $dot.'tiff';
           case
IMAGETYPE_IFF    : return $dot.'aiff';
           case
IMAGETYPE_JB2    : return $dot.'jb2';
           case
IMAGETYPE_JPC    : return $dot.'jpc';
           case
IMAGETYPE_JP2    : return $dot.'jp2';
           case
IMAGETYPE_JPX    : return $dot.'jpf';
           case
IMAGETYPE_SWC    : return $dot.'swc';
           default                : return
false;
       }
   }
}
?>

<getimagesizeimage_type_to_mime_type>
 Last updated: Thu, 19 May 2005
Copyright © 2001-2005 The PHP Group
All rights reserved.
This unofficial mirror is operated at: The Server Pages
Last updated: Thu May 19 17:35:34 2005 CDT