• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP imagecreate函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getAvatar

 public function getAvatar($string, $widthHeight = 12, $theme = 'default')
 {
     $widthHeight = max($widthHeight, 12);
     $md5 = md5($string);
     $fileName = _TMP_DIR_ . '/' . $md5 . '.png';
     if ($this->tmpFileExists($fileName)) {
         return $fileName;
     }
     // Create seed.
     $seed = intval(substr($md5, 0, 6), 16);
     mt_srand($seed);
     $body = array('legs' => mt_rand(0, count($this->availableParts[$theme]['legs']) - 1), 'hair' => mt_rand(0, count($this->availableParts[$theme]['hair']) - 1), 'arms' => mt_rand(0, count($this->availableParts[$theme]['arms']) - 1), 'body' => mt_rand(0, count($this->availableParts[$theme]['body']) - 1), 'eyes' => mt_rand(0, count($this->availableParts[$theme]['eyes']) - 1), 'mouth' => mt_rand(0, count($this->availableParts[$theme]['mouth']) - 1));
     // Avatar random parts.
     $parts = array('legs' => $this->availableParts[$theme]['legs'][$body['legs']], 'hair' => $this->availableParts[$theme]['hair'][$body['hair']], 'arms' => $this->availableParts[$theme]['arms'][$body['arms']], 'body' => $this->availableParts[$theme]['body'][$body['body']], 'eyes' => $this->availableParts[$theme]['eyes'][$body['eyes']], 'mouth' => $this->availableParts[$theme]['mouth'][$body['mouth']]);
     $avatar = imagecreate($widthHeight, $widthHeight);
     imagesavealpha($avatar, true);
     imagealphablending($avatar, false);
     $background = imagecolorallocate($avatar, 0, 0, 0);
     $line_colour = imagecolorallocate($avatar, mt_rand(0, 200) + 55, mt_rand(0, 200) + 55, mt_rand(0, 200) + 55);
     imagecolortransparent($avatar, $background);
     imagefilledrectangle($avatar, 0, 0, $widthHeight, $widthHeight, $background);
     // Fill avatar with random parts.
     foreach ($parts as &$part) {
         $this->drawPart($part, $avatar, $widthHeight, $line_colour, $background);
     }
     imagepng($avatar, $fileName);
     imagecolordeallocate($avatar, $line_colour);
     imagecolordeallocate($avatar, $background);
     imagedestroy($avatar);
     return $fileName;
 }
开发者ID:recallfx,项目名称:monsterid.php,代码行数:31,代码来源:MonsterId.php


示例2: run

 /**
  *	Génère l'avatar
  */
 public function run()
 {
     //On créer l'image avec les dimentions données
     $image = imagecreate($this->_size, $this->_size);
     //On créer la couleur en fonction du hash de la chaine de caractères
     $color = imagecolorallocate($image, hexdec(substr($this->_color, 0, 2)), hexdec(substr($this->_color, 2, 2)), hexdec(substr($this->_color, 4, 2)));
     //on défini le fond de l'image (blanc)
     $bg = imagecolorallocate($image, 255, 255, 255);
     //nombre de blocs à placer dans l'image (taille de l'image/taille des blocs)
     $c = $this->_size / $this->_blockSize;
     for ($x = 0; $x < ceil($c / 2); $x++) {
         for ($y = 0; $y < $c; $y++) {
             // Si le nombre est pair $pixel vaut true sinon $pixel vaut false
             $pixel = hexdec($this->_hash[(int) ($x * ceil($c / 2)) + $y]) % 2 == 0;
             if ($pixel) {
                 $pixelColor = $color;
             } else {
                 $pixelColor = $bg;
             }
             // On place chaque bloc de l'image
             //imagefilledrectangle($image, $x*$this->_blockSize, $y*$this->_blockSize, ($x+1)*$this->_blockSize, ($y+1)*$this->_blockSize, $pixelColor);
             //imagefilledrectangle($image, $this->_size-$x*$this->_blockSize, $y*$this->_blockSize, $this->_size-($x+1)*$this->_blockSize, ($y+1)*$this->_blockSize, $pixelColor);
             imagefilledrectangle($image, $x * $this->_blockSize, $y * $this->_blockSize, ($x + 1) * $this->_blockSize, ($y + 1) * $this->_blockSize, $pixelColor);
             imagefilledrectangle($image, $this->_size - $x * $this->_blockSize, $y * $this->_blockSize, $this->_size - ($x + 1) * $this->_blockSize, ($y + 1) * $this->_blockSize, $pixelColor);
         }
     }
     ob_start();
     imagepng($image);
     //on place l'image en mémoire
     $this->_image = ob_get_contents();
     ob_clean();
 }
开发者ID:JulienCoutault,项目名称:Web,代码行数:35,代码来源:RandomAvatar.php


示例3: executeGetLabel

 public function executeGetLabel()
 {
     $student = StudentPeer::retrieveByPK($this->getRequestParameter('id'));
     $this->forward404Unless($student);
     $this->student = $student;
     define('IMG_FORMAT_PNG', 1);
     define('IMG_FORMAT_JPEG', 2);
     define('IMG_FORMAT_WBMP', 4);
     define('IMG_FORMAT_GIF', 8);
     require 'FColor.php';
     require 'BarCode.php';
     require 'FDrawing.php';
     include 'code128.barcode.php';
     $color_black = new FColor(0, 0, 0);
     $color_white = new FColor(255, 255, 255);
     $code_generated = new code128(32, $color_black, $color_white, 1, $student->getCode(), 3);
     $drawing = new FDrawing(1024, 1024, '', $color_white);
     $drawing->init();
     $drawing->add_barcode($code_generated);
     $drawing->draw_all();
     $im = $drawing->get_im();
     #$im2 = imagecreate($code_generated->lastX,$code_generated->lastY);
     $im2 = imagecreate(300, 100);
     imagecopyresized($im2, $im, 0, 0, 0, 0, 300, 100, 300, 100);
     ##imagecopyresized($im2, $im, 0, 0, 0, 0, $code_generated->lastX, $code_generated->lastY, $code_generated->lastX, $code_generated->lastY);
     $drawing->set_im($im2);
     $drawing->finish(IMG_FORMAT_PNG);
 }
开发者ID:taryono,项目名称:school,代码行数:28,代码来源:actions.class.php


示例4: create

 /**
  * Create a palette image
  *
  * @param int $width
  * @param int $height
  * @return WideImage_PaletteImage
  */
 static function create($width, $height)
 {
     if ($width * $height <= 0 || $width < 0) {
         throw new WideImage_InvalidImageDimensionException("Can't create an image with dimensions [{$width}, {$height}].");
     }
     return new WideImage_PaletteImage(imagecreate($width, $height));
 }
开发者ID:ehazell,项目名称:AZDWR,代码行数:14,代码来源:PaletteImage.php


示例5: getCode

function getCode($num, $w, $h)
{
    // 去掉了 0 1 O l 等
    $str = "23456789abcdefghijkmnpqrstuvwxyz";
    $code = '';
    for ($i = 0; $i < $num; $i++) {
        $code .= $str[mt_rand(0, strlen($str) - 1)];
    }
    //将生成的验证码写入session,备验证页面使用
    $_SESSION["my_checkcode"] = $code;
    //创建图片,定义颜色值
    Header("Content-type: image/PNG");
    $im = imagecreate($w, $h);
    $black = imagecolorallocate($im, mt_rand(0, 200), mt_rand(0, 120), mt_rand(0, 120));
    $gray = imagecolorallocate($im, 118, 151, 199);
    $bgcolor = imagecolorallocate($im, 235, 236, 237);
    //画背景
    imagefilledrectangle($im, 0, 0, $w, $h, $bgcolor);
    //画边框
    imagerectangle($im, 0, 0, $w - 1, $h - 1, $gray);
    //imagefill($im, 0, 0, $bgcolor);
    //在画布上随机生成大量点,起干扰作用;
    for ($i = 0; $i < 80; $i++) {
        imagesetpixel($im, rand(0, $w), rand(0, $h), $black);
    }
    //将字符随机显示在画布上,字符的水平间距和位置都按一定波动范围随机生成
    $strx = rand(5, 10);
    for ($i = 0; $i < $num; $i++) {
        $strpos = rand(1, 6);
        imagestring($im, 20, $strx, $strpos, substr($code, $i, 1), $black);
        $strx += $w / 5;
    }
    imagepng($im);
    imagedestroy($im);
}
开发者ID:hanpc,项目名称:chushen,代码行数:35,代码来源:code_char.php


示例6: mkthumb

function mkthumb($img_src, $img_width = "100", $img_height = "100", $folder_scr = "include/files", $des_src = "include/files")
{
    // Größe und Typ ermitteln
    list($src_width, $src_height, $src_typ) = getimagesize($folder_scr . "/" . $img_src);
    if (!$src_typ) {
        return false;
    }
    // calculate new size
    if ($src_width >= $src_height) {
        $new_image_height = $src_height / $src_width * $img_width;
        $new_image_width = $img_width;
        if ($new_image_height > $img_height) {
            $new_image_width = $new_image_width / $new_image_height * $img_height;
            $new_image_height = $img_height;
        }
    } else {
        $new_image_width = $src_width / $src_height * $img_height;
        $new_image_height = $img_height;
        if ($new_image_width > $img_width) {
            $new_image_height = $new_image_height / $new_image_width * $img_width;
            $new_image_width = $img_width;
        }
    }
    // for the case that the thumbnail would be bigger then the original picture
    if ($new_image_height > $src_height) {
        $new_image_width = $new_image_width * $src_height / $new_image_height;
        $new_image_height = $src_height;
    }
    if ($new_image_width > $src_width) {
        $new_image_height = $new_image_height * $new_image_width / $src_width;
        $new_image_width = $src_width;
    }
    if ($src_typ == 1) {
        $image = imagecreatefromgif($folder_scr . "/" . $img_src);
        $new_image = imagecreate($new_image_width, $new_image_height);
        imagecopyresampled($new_image, $image, 0, 0, 0, 0, $new_image_width, $new_image_height, $src_width, $src_height);
        imagegif($new_image, $des_src . "/" . $img_src . "_thumb", 100);
        imagedestroy($image);
        imagedestroy($new_image);
        return true;
    } elseif ($src_typ == 2) {
        $image = imagecreatefromjpeg($folder_scr . "/" . $img_src);
        $new_image = imagecreatetruecolor($new_image_width, $new_image_height);
        imagecopyresampled($new_image, $image, 0, 0, 0, 0, $new_image_width, $new_image_height, $src_width, $src_height);
        imagejpeg($new_image, $des_src . "/" . $img_src . "_thumb", 100);
        imagedestroy($image);
        imagedestroy($new_image);
        return true;
    } elseif ($src_typ == 3) {
        $image = imagecreatefrompng($folder_scr . "/" . $img_src);
        $new_image = imagecreatetruecolor($new_image_width, $new_image_height);
        imagecopyresampled($new_image, $image, 0, 0, 0, 0, $new_image_width, $new_image_height, $src_width, $src_height);
        imagepng($new_image, $des_src . "/" . $img_src . "_thumb");
        imagedestroy($image);
        imagedestroy($new_image);
        return true;
    } else {
        return false;
    }
}
开发者ID:GoeGaming,项目名称:bans.sevenelevenclan.org,代码行数:60,代码来源:thumbs.inc.php


示例7: index

 public function index()
 {
     $code = substr(sha1(mt_rand()), 17, 6);
     $this->session->set_userdata('captcha_code', $code);
     $width = '120';
     $height = '40';
     $font = APPPATH . 'modules/contact/assets/fonts/monofont.ttf';
     $font_size = $height * 0.75;
     $image = @imagecreate($width, $height) or die('Cannot initialize new GD image stream');
     /* set the colours */
     $background_color = imagecolorallocate($image, 255, 255, 255);
     $text_color = imagecolorallocate($image, 20, 40, 100);
     $noise_color = imagecolorallocate($image, 100, 120, 180);
     /* generate random dots in background */
     for ($i = 0; $i < $width * $height / 3; $i++) {
         imagefilledellipse($image, mt_rand(0, $width), mt_rand(0, $height), 1, 1, $noise_color);
     }
     /* generate random lines in background */
     for ($i = 0; $i < $width * $height / 150; $i++) {
         imageline($image, mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $width), mt_rand(0, $height), $noise_color);
     }
     /* create textbox and add text */
     $textbox = imagettfbbox($font_size, 0, $font, $code) or die('Error in imagettfbbox function');
     $x = ($width - $textbox[4]) / 2;
     $y = ($height - $textbox[5]) / 2;
     imagettftext($image, $font_size, 0, $x, $y, $text_color, $font, $code) or die('Error in imagettftext function');
     /* output captcha image to browser */
     header('Content-Type: image/jpeg');
     imagejpeg($image);
     imagedestroy($image);
 }
开发者ID:binaek89,项目名称:cms-canvas,代码行数:31,代码来源:captcha.php


示例8: graph_error

function graph_error($string)
{
    global $vars, $config, $debug, $graphfile;
    $vars['bg'] = 'FFBBBB';
    include 'includes/graphs/common.inc.php';
    $rrd_options .= ' HRULE:0#555555';
    $rrd_options .= " --title='" . $string . "'";
    rrdtool_graph($graphfile, $rrd_options);
    if ($height > '99') {
        shell_exec($rrd_cmd);
        d_echo('<pre>' . $rrd_cmd . '</pre>');
        if (is_file($graphfile) && !$debug) {
            header('Content-type: image/png');
            $fd = fopen($graphfile, 'r');
            fpassthru($fd);
            fclose($fd);
            unlink($graphfile);
            exit;
        }
    } else {
        if (!$debug) {
            header('Content-type: image/png');
        }
        $im = imagecreate($width, $height);
        $px = (imagesx($im) - 7.5 * strlen($string)) / 2;
        imagestring($im, 3, $px, $height / 2 - 8, $string, imagecolorallocate($im, 128, 0, 0));
        imagepng($im);
        imagedestroy($im);
        exit;
    }
}
开发者ID:greggcz,项目名称:librenms,代码行数:31,代码来源:graph.inc.php


示例9: __construct

 public function __construct($width = '120', $height = '40', $characters = '6')
 {
     $code = $this->generateCode($characters);
     /* font size will be 75% of the image height */
     $font_size = $height * 0.75;
     $image = @imagecreate($width, $height) or die('Cannot initialize new GD image stream');
     /* set the colours */
     $background_color = imagecolorallocate($image, 255, 255, 255);
     $text_color = imagecolorallocate($image, 20, 40, 100);
     $noise_color = imagecolorallocate($image, 100, 120, 180);
     /* generate random dots in background */
     for ($i = 0; $i < $width * $height / 3; $i++) {
         imagefilledellipse($image, mt_rand(0, $width), mt_rand(0, $height), 1, 1, $noise_color);
     }
     /* generate random lines in background */
     for ($i = 0; $i < $width * $height / 150; $i++) {
         imageline($image, mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $width), mt_rand(0, $height), $noise_color);
     }
     /* create textbox and add text */
     $textbox = imagettfbbox($font_size, 0, $this->font, $code) or die('Error in imagettfbbox function');
     $x = ($width - $textbox[4]) / 2;
     $y = ($height - $textbox[5]) / 2;
     imagettftext($image, $font_size, 0, $x, $y, $text_color, $this->font, $code) or die('Error in imagettftext function');
     /* output captcha image to browser */
     header('Content-Type: image/jpeg');
     imagejpeg($image);
     imagedestroy($image);
     /* @var $CI My_Controller */
     $CI = get_instance();
     $CI->session->set_userdata('security_code', $code);
 }
开发者ID:elshafey,项目名称:ir,代码行数:31,代码来源:capatcha.php


示例10: generateAvatarGD

function generateAvatarGD($gdversion, $src_img, $srcWidth, $srcHeight, $dstWidth, $dstHeight, $quality, $location)
{
    if ($srcWidth > $dstWidth || $srcHeight > $dstHeight) {
        $ratio = $srcWidth / $srcHeight;
        if ($dstWidth / $dstHeight > $ratio) {
            $dstWidth = $dstHeight * $ratio;
        } else {
            $dstHeight = $dstWidth / $ratio;
        }
    } else {
        $dstWidth = $srcWidth;
        $dstHeight = $srcHeight;
    }
    if ((int) $gdversion == 1) {
        $dst_img = imagecreate($dstWidth, $dstHeight);
        imagecopyresized($dst_img, $src_img, 0, 0, 0, 0, (int) $dstWidth, (int) $dstHeight, $srcWidth, $srcHeight);
    } else {
        $dst_img = imagecreatetruecolor($dstWidth, $dstHeight);
        imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, (int) $dstWidth, (int) $dstHeight, $srcWidth, $srcHeight);
    }
    $tmpfile = tempnam(CKunenaPath::tmpdir(), "kn_");
    imagejpeg($dst_img, $tmpfile, $quality);
    CKunenaFile::copy($tmpfile, $location);
    unlink($tmpfile);
    imagedestroy($dst_img);
}
开发者ID:kaantunc,项目名称:MYK-BOR,代码行数:26,代码来源:myprofile_avatar_upload.php


示例11: YDGraphPie

 /**
  *  This is the class constructor for the YDGraphPie class.
  *
  *  @param  $width              (optional) the width of the graph in pixels
  *  @param  $height             (optional) the height of the graph in pixels
  *  @param  $margin             (optional) the margin to keep around the graph
  *  @param  $backgroundColor    (optional) the background color for the graph
  */
 function YDGraphPie($width = 400, $height = 300, $margin = 7, $backgroundColor = '#ffffff')
 {
     // Initialize the parent class
     $this->YDAddOnModule();
     // Setup the module
     $this->_author = "David Bittencourt";
     $this->_version = "1.3";
     $this->_copyright = "(c) 2005 David Bittencourt, [email protected]";
     $this->_description = "This class implements a pie chart rendering utility";
     // Setup the defaults
     $this->m_title = "";
     $this->m_width = $width;
     $this->m_height = $height;
     $this->m_image = imagecreate($this->m_width, $this->m_height);
     $this->m_margin = $margin;
     $vBackColor = YDGraph::_decode_color($backgroundColor);
     $this->m_backgroundColor = imagecolorallocate($this->m_image, $vBackColor[0], $vBackColor[1], $vBackColor[2]);
     $this->m_strokeColor = imagecolorallocate($this->m_image, $vBackColor[0], $vBackColor[1], $vBackColor[2]);
     $this->m_fillColor = $this->m_backgroundColor;
     $this->m_numberOfDecimals = 0;
     $this->m_thousandsSeparator = ',';
     $this->m_decimalSeparator = '.';
     $this->m_showtotal = false;
     $this->m_total = null;
     $this->m_formattotal = true;
     $this->m_totalstring = 'Total: ';
 }
开发者ID:BackupTheBerlios,项目名称:ydframework-svn,代码行数:35,代码来源:YDGraphPie.php


示例12: imgcode

function imgcode($nums, $width, $high)
{
    //去除了數字0和1 字母小寫O和L,為了避免辨識不清楚
    //$str = "23456789abcdefghijkmnpqrstuvwxyzABCDEFGHIJKLMOPQRSTUBWXYZ";
    $str = "0123456789";
    $code = '';
    for ($i = 0; $i < $nums; $i++) {
        $code .= $str[mt_rand(0, strlen($str) - 1)];
    }
    $_SESSION['captcha'] = $code;
    //建立圖示,設置寬度及高度與顏色等等條件
    $image = imagecreate($width, $high);
    $black = imagecolorallocate($image, mt_rand(0, 200), mt_rand(0, 200), mt_rand(0, 200));
    $border_color = imagecolorallocate($image, 21, 106, 235);
    $background_color = imagecolorallocate($image, 235, 236, 237);
    //建立圖示背景
    imagefilledrectangle($image, 0, 0, $width, $high, $background_color);
    //建立圖示邊框
    imagerectangle($image, 0, 0, $width - 1, $high - 1, $border_color);
    //在圖示布上隨機產生大量躁點
    for ($i = 0; $i < 80; $i++) {
        imagesetpixel($image, rand(0, $width), rand(0, $high), $black);
    }
    $strx = rand(3, 8);
    for ($i = 0; $i < $nums; $i++) {
        $strpos = rand(1, 6);
        imagestring($image, 5, $strx, $strpos, substr($code, $i, 1), $black);
        $strx += rand(10, 30);
    }
    imagepng($image);
    imagedestroy($image);
}
开发者ID:FantasticThought,项目名称:tfsda,代码行数:32,代码来源:captcha.php


示例13: apply

 function apply(lmbAbstractImageContainer $container)
 {
     list($x, $y, $width, $height) = $this->calculateCropArea($container->getWidth(), $container->getHeight());
     $im = $container->isPallete() ? imagecreate($width, $height) : imagecreatetruecolor($width, $height);
     imagecopy($im, $container->getResource(), 0, 0, $x, $y, $width, $height);
     $container->replaceResource($im);
 }
开发者ID:snowjobgit,项目名称:limb,代码行数:7,代码来源:lmbGdCropImageFilter.class.php


示例14: blank

 public static function blank($width, $height)
 {
     $handle = imagecreate($width, $height);
     $whiteColor = imagecolorallocate($handle, 0xff, 0xff, 0xff);
     $blackColor = imagecolorallocate($handle, 0x0, 0x0, 0x0);
     return new self($handle, $whiteColor, $blackColor);
 }
开发者ID:kofel,项目名称:gutenberg,代码行数:7,代码来源:Image.php


示例15: getCode

 public static function getCode($width = 70, $height = 24, $len = 4)
 {
     self::init();
     header('content-type:image/png');
     $checkWord = '';
     $checkChar = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWXYZ1234567890';
     for ($num = 0; $num < $len; $num++) {
         $char = rand(0, strlen($checkChar) - 1);
         $checkWord .= $checkChar[$char];
     }
     $_SESSION['code'] = strtolower($checkWord);
     $image = imagecreate($width, $height);
     $font = FONTS_PATH . 'ariblk.ttf';
     $red = imagecolorallocate($image, 0xf3, 0x61, 0x61);
     $blue = imagecolorallocate($image, 0x53, 0x68, 0xbd);
     $green = imagecolorallocate($image, 0x6b, 0xc1, 0x46);
     $colors = array($red, $blue, $green);
     $gray = imagecolorallocate($image, 0xf5, 0xf5, 0xf5);
     imagefill($image, 0, 0, $gray);
     imageline($image, rand(0, 5), rand(6, 18), rand(65, 70), rand(6, 18), $colors[rand(0, 2)]);
     for ($num = 0; $num < $len; $num++) {
         imagettftext($image, rand(12, 16), (rand(0, 60) + 330) % 360, 5 + 15 * $num + rand(0, 4), 18 + rand(0, 4), $colors[rand(0, 2)], $font, $checkWord[$num]);
     }
     imagepng($image);
     imagedestroy($image);
 }
开发者ID:soulence1211,项目名称:SOULENCE,代码行数:26,代码来源:Image.php


示例16: return_image

function return_image($boolean)
{
    if (function_exists('imagecreate')) {
        $im = imagecreate(1, 1);
        if ($boolean) {
            imagecolorallocate($im, 0, 255, 0);
        } else {
            imagecolorallocate($im, 255, 0, 0);
        }
        header("Content-type: image/gif");
        imagegif($im);
        imagedestroy($im);
    } else {
        $grape_gif = '
        R0lGODlhIAAgALMAAAAAAAAAgHCAkC6LV76+vvXeswD/ANzc3DLNMubm+v/6zS9PT6Ai8P8A////
        /////yH5BAEAAAkALAAAAAAgACAAAAS00MlJq7046803AF3ofAYYfh8GIEvpoUZcmtOKAO5rLMva
        0rYVKqX5IEq3XDAZo1GGiOhw5rtJc09cVGo7orYwYtYo3d4+DBxJWuSCAQ30+vNTGcxnOIARj3eT
        YhJDQ3woDGl7foNiKBV7aYeEkHEignKFkk4ciYaImJqbkZ+PjZUjaJOElKanqJyRrJyZgSKkokOs
        NYa2q7mcirC5I5FofsK6hcHHgsSgx4a9yzXK0rrV19gRADs=
        ';
        $php_rules = 'iVBORw0KGgoAAAANSUhEUgAAABwAAAASCAMAAAB/2U7WAAAABl' . 'BMVEUAAAD///+l2Z/dAAAASUlEQVR4XqWQUQoAIAxC2/0vXZDr' . 'EX4IJTRkb7lobNUStXsB0jIXIAMSsQnWlsV+wULF4Avk9fLq2r' . '8a5HSE35Q3eO2XP1A1wQkZSgETvDtKdQAAAABJRU5ErkJggg==';
        if ($boolean) {
            $data = base64_decode($grape_gif);
            header("Content-type: image/gif");
        } else {
            $data = base64_decode($php_rules);
            header("Content-type: image/png");
        }
        echo $data;
    }
}
开发者ID:zivkovicp,项目名称:genetify,代码行数:31,代码来源:init.php


示例17: __construct

 /**
  * Class constructor generates the CAPTCHA image.
  *
  * @return blob the image
  * @access public
  */
 function __construct()
 {
     session_start();
     $image = imagecreate($this->width, $this->height);
     $random_str = $this->gen_str($this->chars_nr);
     #md5( microtime() );						// md5 to generate the random string
     $result_str = substr($random_str, 0, $this->chars_nr);
     //trim $chars_nr digit
     $bg_color = imagecolorallocate($image, $this->background_color['red'], $this->background_color['green'], $this->background_color['blue']);
     // background color
     $tx_color = imagecolorallocate($image, $this->text_color['red'], $this->text_color['gree'], $this->text_color['blue']);
     // text color
     for ($i = 0; $i <= $this->lines; $i++) {
         $line_color = imagecolorallocate($image, rand(0, 255), rand(0, 255), rand(0, 255));
         //line color
         imageline($image, rand(rand(-10, 100), rand(-10, 100)), rand(rand(-10, 100), rand(-10, 100)), rand(rand(-10, 100), rand(-10, 100)), rand(rand(-10, 100), rand(-10, 100)), $line_color);
         // Create lines on image
     }
     imagestring($image, 5, 20, 10, $result_str, $tx_color);
     // Draw a random string horizontally
     $_SESSION['key'] = $result_str;
     // Carry the data through session
     header("Content-type: image/png");
     // Out out the image
     imagepng($image);
     // Output image to browser
 }
开发者ID:rehash,项目名称:Repository,代码行数:33,代码来源:class.rshcaptcha.php


示例18: resize_image_gd

function resize_image_gd($src, $dest, $quality, $width, $height, $image_info)
{
    global $convert_options;
    $types = array(1 => "gif", 2 => "jpeg", 3 => "png");
    if ($convert_options['convert_gd2']) {
        $thumb = imagecreatetruecolor($width, $height);
    } else {
        $thumb = imagecreate($width, $height);
    }
    $image_create_handle = "imagecreatefrom" . $types[$image_info[2]];
    if ($image = $image_create_handle($src)) {
        if ($convert_options['convert_gd2']) {
            imagecopyresampled($thumb, $image, 0, 0, 0, 0, $width, $height, ImageSX($image), ImageSY($image));
        } else {
            imagecopyresized($thumb, $image, 0, 0, 0, 0, $width, $height, ImageSX($image), ImageSY($image));
        }
        if ($image_info[2] == 3) {
            $quality = 9;
        }
        $image_handle = "image" . $types[$image_info[2]];
        $image_handle($thumb, $dest, $quality);
        imagedestroy($image);
        imagedestroy($thumb);
    }
    return file_exists($dest) ? 1 : 0;
}
开发者ID:abhinay100,项目名称:fourimages_app,代码行数:26,代码来源:image_utils.php


示例19: resize

 /**
  * Automatically resizes an image and returns formatted IMG tag
  *
  * @param string $path Path to the image file, relative to the webroot/img/ directory.
  * @param integer $width Image of returned image
  * @param integer $height Height of returned image
  * @param boolean $aspect Maintain aspect ratio (default: true)
  * @param array	$htmlAttributes Array of HTML attributes.
  * @param boolean $return Wheter this method should return a value or output it. This overrides AUTO_OUTPUT.
  * @return mixed	Either string or echos the value, depends on AUTO_OUTPUT and $return.
  * @access public
  */
 public function resize($path, $width, $height, $aspect = true, $htmlAttributes = array(), $return = false)
 {
     $types = array(1 => "gif", "jpeg", "png", "swf", "psd", "wbmp");
     // used to determine image type
     if (empty($htmlAttributes['alt'])) {
         $htmlAttributes['alt'] = 'thumb';
     }
     // Ponemos alt default
     $uploadsDir = 'uploads';
     $fullpath = ROOT . DS . APP_DIR . DS . WEBROOT_DIR . DS . $uploadsDir . DS;
     $url = ROOT . DS . APP_DIR . DS . WEBROOT_DIR . DS . $path;
     if (!($size = getimagesize($url))) {
         return;
     }
     // image doesn't exist
     if ($aspect) {
         // adjust to aspect.
         if ($size[1] / $height > $size[0] / $width) {
             // $size[0]:width, [1]:height, [2]:type
             $width = ceil($size[0] / $size[1] * $height);
         } else {
             $height = ceil($width / ($size[0] / $size[1]));
         }
     }
     $relfile = $this->webroot . $uploadsDir . '/' . $this->cacheDir . '/' . $width . 'x' . $height . '_' . basename($path);
     // relative file
     $cachefile = $fullpath . $this->cacheDir . DS . $width . 'x' . $height . '_' . basename($path);
     // location on server
     if (file_exists($cachefile)) {
         $csize = getimagesize($cachefile);
         $cached = $csize[0] == $width && $csize[1] == $height;
         // image is cached
         if (@filemtime($cachefile) < @filemtime($url)) {
             // check if up to date
             $cached = false;
         }
     } else {
         $cached = false;
     }
     if (!$cached) {
         $resize = $size[0] > $width || $size[1] > $height || ($size[0] < $width || $size[1] < $height);
     } else {
         $resize = false;
     }
     if ($resize) {
         $image = call_user_func('imagecreatefrom' . $types[$size[2]], $url);
         if (function_exists("imagecreatetruecolor") && ($temp = imagecreatetruecolor($width, $height))) {
             imagecopyresampled($temp, $image, 0, 0, 0, 0, $width, $height, $size[0], $size[1]);
         } else {
             $temp = imagecreate($width, $height);
             imagecopyresized($temp, $image, 0, 0, 0, 0, $width, $height, $size[0], $size[1]);
         }
         call_user_func("image" . $types[$size[2]], $temp, $cachefile);
         imagedestroy($image);
         imagedestroy($temp);
     } else {
         //copy($url, $cachefile);
     }
     return $this->output(sprintf($this->Html->tags['image'], $relfile, $this->Html->_parseAttributes($htmlAttributes, null, '', ' ')), $return);
 }
开发者ID:rchavik,项目名称:indent-all-the-things,代码行数:72,代码来源:image.php


示例20: captcha

function captcha($width, $height, $code)
{
    $font = "./font/ChalkboardBold.ttf";
    $font_size = 17;
    $image = imagecreate($width, $height);
    $background_color = imagecolorallocate($image, 255, 255, 255);
    $text_color = imagecolorallocate($image, 20, 40, 100);
    $noise_color = imagecolorallocate($image, 100, 120, 180);
    for ($i = 0; $i < $width * $height / 3; $i++) {
        imagefilledellipse($image, mt_rand(0, $width), mt_rand(0, $height), 1, 1, $noise_color);
    }
    for ($i = 0; $i < $width * $height / 150; $i++) {
        imageline($image, mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $width), mt_rand(0, $height), $noise_color);
    }
    $x = 3;
    $y = 20;
    imagettftext($image, $font_size, rand(-45, 45), $x, $y + rand() % 16, $text_color, $font, $code[0]);
    imagettftext($image, $font_size, rand(-45, 45), $x + 23, $y + rand() % 16, $text_color, $font, $code[1]);
    imagettftext($image, $font_size, rand(-45, 45), $x + 46, $y + rand() % 16, $text_color, $font, $code[2]);
    imagettftext($image, $font_size, rand(-45, 45), $x + 69, $y + rand() % 16, $text_color, $font, $code[3]);
    imagettftext($image, $font_size, rand(-45, 45), $x + 92, $y + rand() % 16, $text_color, $font, $code[4]);
    imagettftext($image, $font_size, rand(-45, 45), $x + 115, $y + rand() % 16, $text_color, $font, $code[5]);
    header('Content-Type: image/jpeg');
    imagejpeg($image);
    imagedestroy($image);
}
开发者ID:brenoinojosa,项目名称:ragnarok-public,代码行数:26,代码来源:img.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP imagecreatefrombmp函数代码示例发布时间:2022-05-15
下一篇:
PHP imagecopymergegray函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap