PageRenderTime 17ms CodeModel.GetById 11ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/php/pear/PHP/Compat/Function/image_type_to_mime_type.php

https://gitlab.com/trang1104/portable_project
PHP | 147 lines | 98 code | 21 blank | 28 comment | 18 complexity | 22996605069ad4156b4fca17793f284d MD5 | raw file
  1<?php
  2// +----------------------------------------------------------------------+
  3// | PHP Version 4                                                        |
  4// +----------------------------------------------------------------------+
  5// | Copyright (c) 1997-2004 The PHP Group                                |
  6// +----------------------------------------------------------------------+
  7// | This source file is subject to version 3.0 of the PHP license,       |
  8// | that is bundled with this package in the file LICENSE, and is        |
  9// | available at through the world-wide-web at                           |
 10// | http://www.php.net/license/3_0.txt.                                  |
 11// | If you did not receive a copy of the PHP license and are unable to   |
 12// | obtain it through the world-wide-web, please send a note to          |
 13// | license@php.net so we can mail you a copy immediately.               |
 14// +----------------------------------------------------------------------+
 15// | Authors: Aidan Lister <aidan@php.net>                                |
 16// +----------------------------------------------------------------------+
 17//
 18// $Id: image_type_to_mime_type.php,v 1.8 2005/01/26 04:55:13 aidan Exp $
 19
 20
 21if (!defined('IMAGETYPE_GIF')) {
 22    define('IMAGETYPE_GIF', 1);
 23}
 24
 25if (!defined('IMAGETYPE_JPEG')) {
 26    define('IMAGETYPE_JPEG', 2);
 27}
 28
 29if (!defined('IMAGETYPE_PNG')) {
 30    define('IMAGETYPE_PNG', 3);
 31}
 32
 33if (!defined('IMAGETYPE_SWF')) {
 34    define('IMAGETYPE_SWF', 4);
 35}
 36
 37if (!defined('IMAGETYPE_PSD')) {
 38    define('IMAGETYPE_PSD', 5);
 39}
 40
 41if (!defined('IMAGETYPE_BMP')) {
 42    define('IMAGETYPE_BMP', 6);
 43}
 44
 45if (!defined('IMAGETYPE_TIFF_II')) {
 46    define('IMAGETYPE_TIFF_II', 7);
 47}
 48
 49if (!defined('IMAGETYPE_TIFF_MM')) {
 50    define('IMAGETYPE_TIFF_MM', 8);
 51}
 52
 53if (!defined('IMAGETYPE_JPC')) {
 54    define('IMAGETYPE_JPC', 9);
 55}
 56
 57if (!defined('IMAGETYPE_JP2')) {
 58    define('IMAGETYPE_JP2', 10);
 59}
 60
 61if (!defined('IMAGETYPE_JPX')) {
 62    define('IMAGETYPE_JPX', 11);
 63}
 64
 65if (!defined('IMAGETYPE_JB2')) {
 66    define('IMAGETYPE_JB2', 12);
 67}
 68
 69if (!defined('IMAGETYPE_SWC')) {
 70    define('IMAGETYPE_SWC', 13);
 71}
 72
 73if (!defined('IMAGETYPE_IFF')) {
 74    define('IMAGETYPE_IFF', 14);
 75}
 76
 77if (!defined('IMAGETYPE_WBMP')) {
 78    define('IMAGETYPE_WBMP', 15);
 79}
 80
 81if (!defined('IMAGETYPE_XBM')) {
 82    define('IMAGETYPE_XBM', 16);
 83}
 84
 85
 86/**
 87 * Replace image_type_to_mime_type()
 88 *
 89 * @category    PHP
 90 * @package     PHP_Compat
 91 * @link        http://php.net/function.image_type_to_mime_type
 92 * @author      Aidan Lister <aidan@php.net>
 93 * @version     $Revision: 1.8 $
 94 * @since       PHP 4.3.0
 95 * @require     PHP 4.0.0 (user_error)
 96 */
 97if (!function_exists('image_type_to_mime_type')) {
 98    function image_type_to_mime_type($imagetype)
 99    {
100        switch ($imagetype):
101            case IMAGETYPE_GIF:
102                return 'image/gif';
103                break;
104            case IMAGETYPE_JPEG:
105                return 'image/jpeg';
106                break;
107            case IMAGETYPE_PNG:
108                return 'image/png';
109                break;
110            case IMAGETYPE_SWF:
111            case IMAGETYPE_SWC:
112                return 'application/x-shockwave-flash';
113                break;
114            case IMAGETYPE_PSD:
115                return 'image/psd';
116                break;
117            case IMAGETYPE_BMP:
118                return 'image/bmp';
119                break;
120            case IMAGETYPE_TIFF_MM:
121            case IMAGETYPE_TIFF_II:
122                return 'image/tiff';
123                break;
124            case IMAGETYPE_JP2:
125                return 'image/jp2';
126                break;
127            case IMAGETYPE_IFF:
128                return 'image/iff';
129                break;
130            case IMAGETYPE_WBMP:
131                return 'image/vnd.wap.wbmp';
132                break;
133            case IMAGETYPE_XBM:
134                return 'image/xbm';
135                break;
136            case IMAGETYPE_JPX:
137            case IMAGETYPE_JB2:
138            case IMAGETYPE_JPC:
139            default:
140                return 'application/octet-stream';
141                break;
142
143        endswitch;
144    }
145}
146
147?>