当前位置: 首页>>代码示例>>PHP>>正文


PHP ImageTypes函数代码示例

本文整理汇总了PHP中ImageTypes函数的典型用法代码示例。如果您正苦于以下问题:PHP ImageTypes函数的具体用法?PHP ImageTypes怎么用?PHP ImageTypes使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了ImageTypes函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: IsSupportedType

function IsSupportedType($ext)
{
    $ext = strtolower($ext);
    if (($ext == "jpeg" or $ext == "jpg") and ImageTypes() & IMG_JPG or $ext == "png" and ImageTypes() & IMG_PNG or $ext == "gif" and ImageTypes() & IMG_GIF or $ext == "wbmp" and ImageTypes() & IMG_WBMP or $ext == "bmp" or IsSupportedVideo($ext)) {
        return true;
    } else {
        return false;
    }
}
开发者ID:eistr2n,项目名称:lansuite,代码行数:9,代码来源:show.php

示例2: Image_Transform_GD

 /**
  * Check settings
  *
  * @return mixed true or  or a PEAR error object on error
  *
  * @see PEAR::isError()
  */
 function Image_Transform_GD()
 {
     if (!function_exists("ImageTypes")) {
         return PEAR::raiseError("libgd not compiled into PHP", true);
     }
     if (!ImageTypes()) {
         return PEAR::raiseError("No supported image types available", true);
     }
     return;
 }
开发者ID:BackupTheBerlios,项目名称:logicalframe,代码行数:17,代码来源:GD.php

示例3: IndexAction

 function IndexAction()
 {
     $str = "23456789ABCDEFGHJKMNPQRSTUVWXYZ";
     $code_str = str_shuffle($str);
     $code = str_split(substr($code_str, 0, 4));
     $_SESSION['VerifyCode'] = strtolower(implode('', $code));
     $width = 115;
     $height = 29;
     $im = ImageCreate($width, $height);
     // 创建图形
     ImageColorAllocate($im, 255, 255, 255);
     // 填充背景颜色为白色
     // 用淡色给图形添加杂色
     for ($i = 0; $i < 100; $i++) {
         $pxcolor = ImageColorAllocate($im, 230, 104, 66);
         ImageSetPixel($im, mt_rand(0, $width), mt_rand(0, $height), $pxcolor);
     }
     // 用深色调绘制边框
     $bordercolor = ImageColorAllocate($im, 255, 255, 255);
     ImageRectangle($im, 0, 0, $width - 1, $height - 1, $bordercolor);
     $offset = rand(10, 30);
     $font = array('View/font/UniversityRomanStd.otf');
     foreach ($code as $char) {
         $textcolor = ImageColorAllocate($im, 230, 104, 106);
         shuffle($font);
         imagettftext($im, 22, rand(-20, 40), $offset, 26, $textcolor, $font[0], $char);
         $offset += $width / 5 - rand(0, 2);
     }
     $code_str = str_shuffle($str);
     $code = str_split(substr($code_str, 0, 5));
     // 干扰字符
     $offset = rand(10, 30);
     foreach ($code as $char) {
         $textcolor = ImageColorAllocate($im, 230, 104, 66);
         shuffle($font);
         imagettftext($im, 8, rand(-20, 40), $offset, 26, $textcolor, $font[0], $char);
         $offset += rand(5, 10);
     }
     // 禁止缓存
     header("pragma:no-cache\r\n");
     header("Cache-Control:no-cache\r\n");
     header("Expires:0\r\n");
     if (ImageTypes() & IMG_PNG) {
         header('Content-Type:image/png');
         ImagePNG($im);
     } elseif (ImageTypes() & IMG_JPEG) {
         header('Content-Type:image/jpeg');
         ImageJPEG($im);
     } else {
         header('Content-Type:image/gif');
         ImageGif($im);
     }
 }
开发者ID:logdns,项目名称:amh-4.2,代码行数:53,代码来源:VerifyCode.php

示例4: run

 function run($dbi, $argstr, &$request, $basepage)
 {
     if (ImageTypes() & IMG_PNG) {
         // we have gd & png so go ahead.
         $args = $this->getArgs($argstr, $request);
         return $this->text2png($args);
     } else {
         // we don't have png and/or gd.
         $error_html = _("Sorry, this version of PHP cannot create PNG image files.");
         $link = "http://www.php.net/manual/pl/ref.image.php";
         $error_html .= sprintf(_("See %s"), $link) . ".";
         trigger_error($error_html, E_USER_NOTICE);
         return;
     }
 }
开发者ID:hugcoday,项目名称:wiki,代码行数:15,代码来源:text2png.php

示例5: ShowImageHeader

function ShowImageHeader($ImageHandle)
{
    if (ImageTypes() & IMG_PNG) {
        Header("Content-type: image/png");
        ImagePng($ImageHandle);
    } elseif (ImageTypes() & IMG_GIF) {
        Header("Content-type: image/gif");
        ImageGif($ImageHandle);
    } elseif (ImageTypes() & IMG_JPEG) {
        Header("Content-type: image/jpeg");
        ImageJpeg($ImageHandle, "", 0.5);
    } else {
        die("No images support");
    }
    ImageDestroy($ImageHandle);
}
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:16,代码来源:img.php

示例6: VeriWord

 function VeriWord()
 {
     // Get Font-Files
     $handle = opendir($this->dir_font);
     $pre = 'captcha_';
     while ($file = readdir($handle)) {
         if ($file != "." && $file != ".." && !is_dir($this->dir_font . $file)) {
             $nfo = pathinfo($this->dir_font . $file);
             $prefix = substr($nfo['basename'], 0, strlen($pre));
             if ($nfo['extension'] == 'ttf' && $prefix == $pre) {
                 $this->fonts[] = $nfo['basename'];
             }
         }
     }
     // Get Noise-Files
     $handle = opendir($this->dir_noise);
     while ($file = readdir($handle)) {
         if ($file != "." && $file != ".." && !is_dir($this->dir_noise . $file)) {
             $nfo = pathinfo($this->dir_noise . $file);
             if ($nfo['extension'] == 'jpg' || $nfo['extension'] == 'jpeg') {
                 $this->noises[] = $nfo['basename'];
             }
         }
     }
     ImageTypes();
     $lang = new lang();
     $lang->group("thumbnail.class");
     $this->lang = $lang->return_array();
     if (function_exists('imagejpeg') && IMG_JPEG) {
         define('IMAGEJPEG', true);
     } else {
         define('IMAGEJPEG', false);
     }
     if (function_exists('imagegif') && IMG_GIF) {
         define('IMAGEGIF', true);
     } else {
         define('IMAGEGIF', false);
     }
     if (function_exists('imagepng') && IMG_PNG) {
         define('IMAGEPNG', true);
     } else {
         define('IMAGEPNG', false);
     }
     srand((double) microtime() * time());
     mt_srand((double) microtime() * 1000000);
 }
开发者ID:BackupTheBerlios,项目名称:viscacha-svn,代码行数:46,代码来源:class.veriword.php

示例7: phpAds_GDImageFormat

function phpAds_GDImageFormat()
{
    $conf = $GLOBALS['_MAX']['CONF'];
    global $phpAds_GDImageFormat;
    // Determine php version
    $phpversion = preg_replace("/([^0-9])/D", "", phpversion());
    $phpversion = $phpversion / pow(10, strlen($phpversion) - 1);
    if ($phpversion >= 4.02 || $phpversion >= 3.018 && $phpversion < 4.0) {
        // Determine if GD is installed
        if (extension_loaded("gd")) {
            // Use ImageTypes() to dermine image format
            if (ImageTypes() & IMG_PNG) {
                $phpAds_GDImageFormat = "png";
            } elseif (ImageTypes() & IMG_JPG) {
                $phpAds_GDImageFormat = "jpeg";
            } elseif (ImageTypes() & IMG_GIF) {
                $phpAds_GDImageFormat = "gif";
            } else {
                $phpAds_GDImageFormat = "none";
            }
        } else {
            $phpAds_GDImageFormat = "none";
        }
    } elseif ($phpversion >= 4) {
        // No way to determine image format
        $phpAds_GDImageFormat = "gif";
        // assume gif?
    } else {
        // Use Function_Exists to determine image format
        if (function_exists("imagepng")) {
            $phpAds_GDImageFormat = "png";
        } elseif (function_exists("imagejpeg")) {
            $phpAds_GDImageFormat = "jpeg";
        } elseif (function_exists("imagegif")) {
            $phpAds_GDImageFormat = "gif";
        } else {
            $phpAds_GDImageFormat = "none";
        }
    }
    // Override detected GD foramt
    if (isset($pref['override_gd_imageformat']) && $pref['override_gd_imageformat'] != '') {
        $phpAds_GDImageFormat = $pref['override_gd_imageformat'];
    }
    return $phpAds_GDImageFormat;
}
开发者ID:SamWinchester,项目名称:revive-adserver,代码行数:45,代码来源:lib-gd.inc.php

示例8: makeImage

 function makeImage($session_expired_lang = 'Session Error<br>Refresh the Page')
 {
     global $config, $gpc;
     $challenge = $gpc->get('challenge');
     $this->settings['colortext'] = (bool) $config['botgfxtest_colortext'];
     $this->settings['filter'] = (bool) $config['botgfxtest_filter'];
     $jpeg_quality = (int) $config['botgfxtest_quality'];
     $format = $config['botgfxtest_format'] == 'png' ? 'PNG' : 'JPEG';
     if ((ImageTypes() & constant("IMG_{$format}")) == false) {
         $format = $format == 'PNG' ? 'JPEG' : 'PNG';
     }
     $lines = file($this->datasource);
     $lines = array_map('trim', $lines);
     foreach ($lines as $row) {
         if (empty($row)) {
             continue;
         }
         $data = explode("\t", $row);
         if ($data[0] == $challenge) {
             $this->session = array('word' => $data[2], 'id' => $data[1]);
             break;
         }
     }
     if (empty($this->session['word'])) {
         $this->_errorImage($session_expired_lang);
     }
     // Generate the image
     $im = $this->_drawImage();
     send_nocache_header();
     switch ($format) {
         case 'PNG':
             header("Content-type: image/png");
             imagepng($im);
             break;
         default:
             header("Content-type: image/jpeg");
             imagejpeg($im, '', $jpeg_quality);
     }
     imagedestroy($im);
 }
开发者ID:BackupTheBerlios,项目名称:viscacha-svn,代码行数:40,代码来源:class.veriword.php

示例9: thumbnail

 function thumbnail()
 {
     ImageTypes();
     $lang = new lang();
     $this->lang = $lang->return_array("classes");
     $this->path = '';
     $this->mime = array();
     if (viscacha_function_exists('imagejpeg') && IMG_JPEG) {
         define('IMAGEJPEG', true);
     } else {
         define('IMAGEJPEG', false);
     }
     if (viscacha_function_exists('imagegif') && IMG_GIF) {
         define('IMAGEGIF', true);
     } else {
         define('IMAGEGIF', false);
     }
     if (viscacha_function_exists('imagepng') && IMG_PNG) {
         define('IMAGEPNG', true);
     } else {
         define('IMAGEPNG', false);
     }
 }
开发者ID:BackupTheBerlios,项目名称:viscacha-svn,代码行数:23,代码来源:class.thumbnail.php

示例10: ReadImageFromFile

 function ReadImageFromFile($filename, $type)
 {
     $imagetypes = ImageTypes();
     switch ($type) {
         case 1:
             if ($imagetypes & IMG_GIF) {
                 return ImageCreateFromGIF($filename);
             } else {
                 $msg = "File type <b>.gif</b> not supported by GD version on server.";
                 $page = "?xl=Home";
                 page_load2($msg, $page);
                 return false;
             }
             break;
         case 2:
             if ($imagetypes & IMG_JPEG) {
                 return ImageCreateFromJPEG($filename);
             } else {
                 $msg = "File type <b>.jpg</b> not supported by GD version on server.";
                 $page = "?xl=Home";
                 page_load2($msg, $page);
                 return false;
             }
             break;
         case 3:
             if ($imagetypes & IMG_PNG) {
                 return ImageCreateFromPNG($filename);
             } else {
                 $msg = "File type <b>.png</b> not supported by GD version on server.";
                 $page = "?xl=Home";
                 page_load2($msg, $page);
                 return false;
             }
             break;
         default:
             echo "Chỉ hỗ trợ các loại tập tin với định dạng GIF,JPEG,PNG";
             return 0;
     }
 }
开发者ID:heozung,项目名称:Catch.Up.With,代码行数:39,代码来源:admin.gallery.php

示例11: ErrorImage

 function ErrorImage($text, $width = 0, $height = 0, $forcedisplay = false)
 {
     $width = $width ? $width : $this->config_error_image_width;
     $height = $height ? $height : $this->config_error_image_height;
     $text = 'phpThumb() v' . $this->phpthumb_version . "\n" . 'http://phpthumb.sourceforge.net' . "\n\n" . ($this->config_disable_debug ? 'Error messages disabled' : $text);
     $this->FatalError($text);
     $this->DebugMessage($text, __FILE__, __LINE__);
     $this->purgeTempFiles();
     if ($this->phpThumbDebug && !$forcedisplay) {
         return false;
     }
     if (!$this->config_error_die_on_error && !$forcedisplay) {
         return false;
     }
     if ($this->config_error_silent_die_on_error) {
         exit;
     }
     if ($this->err || $this->config_error_message_image_default) {
         // Show generic custom error image instead of error message
         // for use on production sites where you don't want debug messages
         if ($this->err == 'showerror' || $this->phpThumbDebug) {
             // fall through and actually show error message even if default error image is set
         } else {
             header('Location: ' . ($this->err ? $this->err : $this->config_error_message_image_default));
             exit;
         }
     }
     $this->setOutputFormat();
     if (!$this->thumbnailFormat || phpthumb_functions::gd_version() < 1) {
         $this->thumbnailFormat = 'text';
     }
     if (@$this->thumbnailFormat == 'text') {
         // bypass all GD functions and output text error message
         if (!headers_sent()) {
             header('Content-type: text/plain');
             echo $text;
         } else {
             echo '<pre>' . htmlspecialchars($text) . '</pre>';
         }
         exit;
     }
     $FontWidth = ImageFontWidth($this->config_error_fontsize);
     $FontHeight = ImageFontHeight($this->config_error_fontsize);
     $LinesOfText = explode("\n", @wordwrap($text, floor($width / $FontWidth), "\n", true));
     $height = max($height, count($LinesOfText) * $FontHeight);
     $headers_file = '';
     $headers_line = '';
     if (phpthumb_functions::version_compare_replacement(phpversion(), '4.3.0', '>=') && headers_sent($headers_file, $headers_line)) {
         echo "\n" . '**Headers already sent in file "' . $headers_file . '" on line "' . $headers_line . '", dumping error message as text:**<br><pre>' . "\n\n" . $text . "\n" . '</pre>';
     } elseif (headers_sent()) {
         echo "\n" . '**Headers already sent, dumping error message as text:**<br><pre>' . "\n\n" . $text . "\n" . '</pre>';
     } elseif ($gdimg_error = ImageCreate($width, $height)) {
         $background_color = phpthumb_functions::ImageHexColorAllocate($gdimg_error, $this->config_error_bgcolor, true);
         $text_color = phpthumb_functions::ImageHexColorAllocate($gdimg_error, $this->config_error_textcolor, true);
         ImageFilledRectangle($gdimg_error, 0, 0, $width, $height, $background_color);
         $lineYoffset = 0;
         foreach ($LinesOfText as $line) {
             ImageString($gdimg_error, $this->config_error_fontsize, 2, $lineYoffset, $line, $text_color);
             $lineYoffset += $FontHeight;
         }
         if (function_exists('ImageTypes')) {
             $imagetypes = ImageTypes();
             if ($imagetypes & IMG_PNG) {
                 header('Content-Type: image/png');
                 ImagePNG($gdimg_error);
             } elseif ($imagetypes & IMG_GIF) {
                 header('Content-Type: image/gif');
                 ImageGIF($gdimg_error);
             } elseif ($imagetypes & IMG_JPG) {
                 header('Content-Type: image/jpeg');
                 ImageJPEG($gdimg_error);
             } elseif ($imagetypes & IMG_WBMP) {
                 header('Content-Type: image/vnd.wap.wbmp');
                 ImageWBMP($gdimg_error);
             }
         }
         ImageDestroy($gdimg_error);
     }
     if (!headers_sent()) {
         echo "\n" . '**Failed to send graphical error image, dumping error message as text:**<br>' . "\n\n" . $text;
     }
     exit;
     return true;
 }
开发者ID:notzen,项目名称:exponent-cms,代码行数:84,代码来源:phpthumb.class.php

示例12: setType

 public function setType($type)
 {
     if (!(ImageTypes() & $type)) {
         throw new \InvalidArgumentException('Invalid type');
     }
     $this->type = $type;
     if ($this->fileName) {
         $baseName = pathinfo($this->fileName, PATHINFO_FILENAME);
         $pathName = pathinfo($this->fileName, PATHINFO_DIRNAME);
         $extension = image_type_to_extension($this->type);
         $this->fileName = $pathName . '/' . $baseName . $extension;
     }
 }
开发者ID:CeusMedia,项目名称:Image,代码行数:13,代码来源:Image.php

示例13: ErrorImage

 function ErrorImage($text, $width = 400, $height = 100)
 {
     $this->error = $text;
     if (!$this->config_error_die_on_error) {
         return true;
     }
     if (!empty($this->err) || !empty($this->config_error_message_image_default)) {
         // Show generic custom error image instead of error message
         // for use on production sites where you don't want debug messages
         if (@$this->err == 'showerror') {
             // fall through and actually show error message even if default error image is set
         } else {
             header('Location: ' . (!empty($this->err) ? $this->err : $this->config_error_message_image_default));
             exit;
         }
     }
     if (@$this->f == 'text') {
         // bypass all GD functions and output text error message
         die('<PRE>' . $text . '</PRE>');
     }
     $FontWidth = ImageFontWidth($this->config_error_fontsize);
     $FontHeight = ImageFontHeight($this->config_error_fontsize);
     $LinesOfText = explode("\n", wordwrap($text, floor($width / $FontWidth), "\n", true));
     $height = max($height, count($LinesOfText) * $FontHeight);
     if (headers_sent()) {
         echo "\n" . '**Headers already sent, dumping error message as text:**<br>' . "\n\n" . $text;
     } elseif ($gdimg_error = @ImageCreate($width, $height)) {
         $background_color = phpthumb_functions::ImageHexColorAllocate($gdimg_error, $this->config_error_bgcolor, true);
         $text_color = phpthumb_functions::ImageHexColorAllocate($gdimg_error, $this->config_error_textcolor, true);
         ImageFilledRectangle($gdimg_error, 0, 0, $width, $height, $background_color);
         $lineYoffset = 0;
         foreach ($LinesOfText as $line) {
             ImageString($gdimg_error, $this->config_error_fontsize, 2, $lineYoffset, $line, $text_color);
             $lineYoffset += $FontHeight;
         }
         if (function_exists('ImageTypes')) {
             $imagetypes = ImageTypes();
             if ($imagetypes & IMG_PNG) {
                 header('Content-type: image/png');
                 ImagePNG($gdimg_error);
             } elseif ($imagetypes & IMG_GIF) {
                 header('Content-type: image/gif');
                 ImageGIF($gdimg_error);
             } elseif ($imagetypes & IMG_JPG) {
                 header('Content-type: image/jpeg');
                 ImageJPEG($gdimg_error);
             } elseif ($imagetypes & IMG_WBMP) {
                 header('Content-type: image/wbmp');
                 ImageWBMP($gdimg_error);
             }
         }
         ImageDestroy($gdimg_error);
     }
     if (!headers_sent()) {
         echo "\n" . '**Failed to send graphical error image, dumping error message as text:**<br>' . "\n\n" . $text;
     }
     exit;
     return true;
 }
开发者ID:BackupTheBerlios,项目名称:ydframework-svn,代码行数:59,代码来源:phpthumb.class.php

示例14: imagecopyresampled

 imagecopyresampled($image_p, $im, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
 $thumb_file = substr($name, 0, strrpos($name, '.'));
 if (!preg_match("/(^[.a-zA-Z0-9-+_%&\$§~ ])/i", $thumb_file)) {
     $thumb_file = "non-ASCII";
     //  replacement for non-ASCII names. Visable only as name in thumbs subfolder
 }
 mysqltest();
 //  define thumbnail file
 if (ImageTypes() & IMG_GIF) {
     //  does gd-library support png ?
     $output = "." . $thumb_folder . "/" . $dba_act . "..." . $mysql_table_prefix . "..." . $link_id . "_-_" . $media_id . "-_-" . $thumb_file . ".gif";
     // create name for thumbnail
     imagegif($image_p, $output);
     // make a .gif file
 } else {
     if (ImageTypes() & IMG_PNG) {
         //  does gd-library support gif?
         $output = "." . $thumb_folder . "/" . $dba_act . "..." . $mysql_table_prefix . "..." . $link_id . "_-_" . $media_id . "-_-" . $thumb_file . ".png";
         imagepng($image_p, $output);
     }
 }
 //echo "\r\n\r\n<br /> output: $output<br />\r\n";
 //echo "\r\n\r\n<br /> image_p1: $image_p<br />\r\n";
 if ($output == '') {
     $output = "." . $thumb_folder . "/dummy.png";
     // no GD-library support for gif and png
 }
 $thumb = $db_con->real_escape_string(file_get_contents($output));
 mysqltest();
 //      store actual image in database
 $sql_query = "UPDATE " . $mysql_table_prefix . "media set thumbnail='{$thumb}' where media_link like '{$sql_link}' ";
开发者ID:hackersforcharity,项目名称:rachelpiOS,代码行数:31,代码来源:index_media.php

示例15: read_image_from_file

 function read_image_from_file($filename, $type)
 {
     $imagetypes = ImageTypes();
     switch ($type) {
         case 1:
             if ($imagetypes & IMG_GIF) {
                 return $im = ImageCreateFromGIF($filename);
             }
             break;
         case 2:
             if ($imagetypes & IMG_JPEG) {
                 return ImageCreateFromJPEG($filename);
             }
             break;
         case 3:
             if ($imagetypes & IMG_PNG) {
                 return ImageCreateFromPNG($filename);
             }
             break;
         default:
             return 0;
     }
 }
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:23,代码来源:lib.php


注:本文中的ImageTypes函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。