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


PHP imagefill函数代码示例

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


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

示例1: load

 static function load($filename)
 {
     $info = getimagesize($filename);
     list($width, $height) = $info;
     if (!$width || !$height) {
         return null;
     }
     $image = null;
     switch ($info['mime']) {
         case 'image/gif':
             $image = imagecreatefromgif($filename);
             break;
         case 'image/jpeg':
             $image = imagecreatefromjpeg($filename);
             break;
         case 'image/png':
             $image = imagecreatetruecolor($width, $height);
             $white = imagecolorallocate($image, 255, 255, 255);
             imagefill($image, 0, 0, $white);
             $png = imagecreatefrompng($filename);
             imagealphablending($png, true);
             imagesavealpha($png, true);
             imagecopy($image, $png, 0, 0, 0, 0, $width, $height);
             imagedestroy($png);
             break;
     }
     if ($image) {
         return new image($image, $width, $height);
     } else {
         return null;
     }
 }
开发者ID:nyan-cat,项目名称:easyweb,代码行数:32,代码来源:image.php

示例2: render

 /**
  * @return ZipInterface
  */
 public function render()
 {
     $pathThumbnail = $this->getPresentation()->getPresentationProperties()->getThumbnailPath();
     if ($pathThumbnail) {
         // Size : 128x128 pixel
         // PNG : 8bit, non-interlaced with full alpha transparency
         $gdImage = imagecreatefromstring(file_get_contents($pathThumbnail));
         if ($gdImage) {
             list($width, $height) = getimagesize($pathThumbnail);
             $gdRender = imagecreatetruecolor(128, 128);
             $colorBgAlpha = imagecolorallocatealpha($gdRender, 0, 0, 0, 127);
             imagecolortransparent($gdRender, $colorBgAlpha);
             imagefill($gdRender, 0, 0, $colorBgAlpha);
             imagecopyresampled($gdRender, $gdImage, 0, 0, 0, 0, 128, 128, $width, $height);
             imagetruecolortopalette($gdRender, false, 255);
             imagesavealpha($gdRender, true);
             ob_start();
             imagepng($gdRender);
             $imageContents = ob_get_contents();
             ob_end_clean();
             imagedestroy($gdRender);
             imagedestroy($gdImage);
             $this->getZip()->addFromString('Thumbnails/thumbnail.png', $imageContents);
         }
     }
     return $this->getZip();
 }
开发者ID:phpoffice,项目名称:phppowerpoint,代码行数:30,代码来源:ThumbnailsThumbnail.php

示例3: save

 public function save()
 {
     $maxHeight = 0;
     $width = 0;
     foreach ($this->_segmentsArray as $segment) {
         $maxHeight = max($maxHeight, $segment->height);
         $width += $segment->width;
     }
     // create our canvas
     $img = imagecreatetruecolor($width, $maxHeight);
     $background = imagecolorallocatealpha($img, 255, 255, 255, 127);
     imagefill($img, 0, 0, $background);
     imagealphablending($img, false);
     imagesavealpha($img, true);
     // start placing our images on a single x axis
     $xPos = 0;
     foreach ($this->_segmentsArray as $segment) {
         $tmp = imagecreatefromjpeg($segment->pathToImage);
         imagecopy($img, $tmp, $xPos, 0, 0, 0, $segment->width, $segment->height);
         $xPos += $segment->width;
         imagedestroy($tmp);
     }
     // create our final output image.
     imagepng($img, $this->_saveToPath);
 }
开发者ID:ejacobs,项目名称:css-sprite,代码行数:25,代码来源:CssSprite.php

示例4: embroidery2image

function embroidery2image($embroidery, $scale_post = 1, $scale_pre = false)
{
    // Create image
    $im = imagecreatetruecolor(ceil($embroidery->imageWidth * $scale_post), ceil($embroidery->imageHeight * $scale_post));
    imagesavealpha($im, true);
    imagealphablending($im, false);
    $color = imagecolorallocatealpha($im, 255, 255, 255, 127);
    imagefill($im, 0, 0, $color);
    // Draw stitches
    foreach ($embroidery->blocks as $block) {
        $color = imagecolorallocate($im, $block->color->r, $block->color->g, $block->color->b);
        $x = false;
        foreach ($block->stitches as $stitch) {
            if ($x !== false) {
                imageline($im, ($x - $embroidery->min->x) * $scale_post, ($y - $embroidery->min->y) * $scale_post, ($stitch->x - $embroidery->min->x) * $scale_post, ($stitch->y - $embroidery->min->y) * $scale_post, $color);
            }
            $x = $stitch->x;
            $y = $stitch->y;
        }
    }
    // Scale finished image
    if ($scale_pre) {
        $im2 = imagecreatetruecolor($embroidery->imageWidth * $scale_post * $scale_pre, $embroidery->imageHeight * $scale_post * $scale_pre);
        imagesavealpha($im2, true);
        imagealphablending($im2, false);
        imagecopyresized($im2, $im, 0, 0, 0, 0, $embroidery->imageWidth * $scale_post * $scale_pre, $embroidery->imageHeight * $scale_post * $scale_pre, $embroidery->imageWidth * $scale_post, $embroidery->imageHeight * $scale_post);
        imagedestroy($im);
        $im = $im2;
    }
    return $im;
}
开发者ID:bobosch,项目名称:embroidery,代码行数:31,代码来源:embroidery2image.php

示例5: draw

 /**
  * 2015-12-08
  * Точка отсчёта системы координат [0, 0] — это самая левая верхняя точка холста.
  * Далее кординаты увеличиваются вниз и вправо.
  * @override
  * @see \Df\GoogleFont\Fonts\Png::draw()
  * @used-by \Df\GoogleFont\Fonts\Png::image()
  * @param resource $image
  * @return void
  */
 protected function draw($image)
 {
     $r = imagefill($image, 0, 0, $this->colorAllocateAlpha($image, $this->bgColor()));
     df_assert($r);
     $r = imagettftext($image, $this->fontSize(), 0, $this->marginLeft(), $this->height() - abs($this->contentBottomY()), $this->colorAllocateAlpha($image, $this->fontColor()), $this->ttfPath(), $this->text());
     df_assert($r);
 }
开发者ID:mage2pro,项目名称:google-font,代码行数:17,代码来源:Preview.php

示例6: codeimage

 static function codeimage()
 {
     $image = imagecreatetruecolor(100, 30);
     $bgcolor = imagecolorallocate($image, 255, 255, 255);
     imagefill($image, 0, 0, $bgcolor);
     $code = '';
     for ($i = 0; $i < 4; $i++) {
         $fontsize = 6;
         $fontcolor = imagecolorallocate($image, rand(0, 120), rand(0, 120), rand(0, 120));
         $data = "abcdefghjkmnpqrstuvwxy3456789";
         $fontcontent = substr($data, rand(1, strlen($data) - 1), 1);
         $code .= $fontcontent;
         $x = $i * 100 / 4 + rand(5, 10);
         $y = rand(5, 10);
         imagestring($image, $fontsize, $x, $y, $fontcontent, $fontcolor);
     }
     for ($i = 0; $i < 200; $i++) {
         $pointcolor = imagecolorallocate($image, rand(50, 200), rand(50, 200), rand(50, 200));
         imagesetpixel($image, rand(1, 99), rand(1, 29), $pointcolor);
     }
     for ($i = 0; $i < 2; $i++) {
         $linecolor = imagecolorallocate($image, rand(80, 220), rand(80, 220), rand(80, 220));
         imageline($image, rand(1, 99), rand(1, 29), rand(1, 99), rand(1, 29), $linecolor);
     }
     $return['code'] = $code;
     $return['image'] = $image;
     return $return;
     //		header('content-type:image/png');
     //		imagepng($image);
 }
开发者ID:HivenKay,项目名称:ESalon,代码行数:30,代码来源:LfCodeimage.php

示例7: zoom

namespace common;

class upload
{
    //从tmp中移动upload
    public static function zoom(&$file, &$maxWidth = 0, &$maxHeight = 0)
    {
        list($width, $height, $im, $func, $ext) = self::_init($file);
        if (!$im) {
            \yk\log::runlog('file upload error: im not found', 'upload');
            return false;
        }
        if ($maxWidth > 0) {
            $p = max($width / $maxWidth, $height / $maxHeight);
            $dstwidth = intval($width / $p);
            $dstheight = intval($height / $p);
        } else {
            $dstwidth = $width;
            $dstheight = $height;
        }
        $maxWidth = $dstwidth;
        $maxHeight = $dstheight;
        $dstim = imagecreatetruecolor($dstwidth, $dstheight);
        imagealphablending($dstim, false);
        //关闭混杂模式,不可缺少,  PHP文档中说明: (在非混色模式下,画笔颜色连同其 alpha 通道信息一起被拷贝,替换掉目标像素。混色模式在画调色板图像时不可用。)  而且是imagesavealpha方法起作用的前置步骤.
        imagesavealpha($dstim, true);
        //保存 PNG 图像时保存完整的 alpha 通道信息
        $transparent = imagecolorallocatealpha($dstim, 255, 255, 255, 127);
        //取得一个透明的颜色,  透明度在 0-127 间
        imagefill($dstim, 0, 0, $transparent);
        imagecopyresampled($dstim, $im, 0, 0, 0, 0, $dstwidth, $dstheight, $width, $height);
        $file = uniqid() . $ext;
开发者ID:xiaoniainiu,项目名称:php-yaf-yk,代码行数:32,代码来源:upload.php

示例8: image

 private static function image($frame, $pixelPerPoint = 4, $outerFrame = 4)
 {
     $h = count($frame);
     $w = strlen($frame[0]);
     $imgW = $w + 2 * $outerFrame;
     $imgH = $h + 2 * $outerFrame;
     $base_image = imagecreatetruecolor($imgW, $imgH);
     $col[0] = ImageColorAllocate($base_image, 255, 0, 255);
     $col[1] = ImageColorAllocate($base_image, 0, 0, 0);
     imagecolortransparent($base_image, $col[0]);
     imagealphablending($base_image, true);
     imagesavealpha($base_image, true);
     //        imagefill($base_image, 0, 0, $col[0]);
     imagefill($base_image, 0, 0, 0x7fff0000);
     for ($y = 0; $y < $h; $y++) {
         for ($x = 0; $x < $w; $x++) {
             if ($frame[$y][$x] == '1') {
                 ImageSetPixel($base_image, $x + $outerFrame, $y + $outerFrame, $col[1]);
             }
         }
     }
     $target_image = ImageCreate($imgW * $pixelPerPoint, $imgH * $pixelPerPoint);
     ImageCopyResized($target_image, $base_image, 0, 0, 0, 0, $imgW * $pixelPerPoint, $imgH * $pixelPerPoint, $imgW, $imgH);
     ImageDestroy($base_image);
     return $target_image;
 }
开发者ID:aplitax,项目名称:PHPQRCode,代码行数:26,代码来源:QRimage.php

示例9: getAuthImage

 function getAuthImage($text)
 {
     $this->setpin($text);
     $im_x = 160;
     $im_y = 40;
     $im = imagecreatetruecolor($im_x, $im_y);
     $text_c = ImageColorAllocate($im, mt_rand(0, 100), mt_rand(0, 100), mt_rand(0, 100));
     $tmpC0 = mt_rand(100, 255);
     $tmpC1 = mt_rand(100, 255);
     $tmpC2 = mt_rand(100, 255);
     $buttum_c = ImageColorAllocate($im, $tmpC0, $tmpC1, $tmpC2);
     imagefill($im, 16, 13, $buttum_c);
     $font = PATH_SYS_PUBLIC . 'font-awesome/fonts/verdana.ttf';
     for ($i = 0; $i < strlen($text); $i++) {
         $tmp = substr($text, $i, 1);
         $array = array(-1, 1);
         $p = array_rand($array);
         $an = $array[$p] * mt_rand(1, 10);
         //角度
         $size = 28;
         imagettftext($im, $size, $an, 15 + $i * $size, 35, $text_c, $font, $tmp);
     }
     $distortion_im = imagecreatetruecolor($im_x, $im_y);
     imagefill($distortion_im, 16, 13, $buttum_c);
     for ($i = 0; $i < $im_x; $i++) {
         for ($j = 0; $j < $im_y; $j++) {
             $rgb = imagecolorat($im, $i, $j);
             if ((int) ($i + 20 + sin($j / $im_y * 2 * M_PI) * 10) <= imagesx($distortion_im) && (int) ($i + 20 + sin($j / $im_y * 2 * M_PI) * 10) >= 0) {
                 imagesetpixel($distortion_im, (int) ($i + 10 + sin($j / $im_y * 2 * M_PI - M_PI * 0.1) * 4), $j, $rgb);
             }
         }
     }
     //加入干扰象素;
     $count = 160;
     //干扰像素的数量
     for ($i = 0; $i < $count; $i++) {
         $randcolor = ImageColorallocate($distortion_im, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
         imagesetpixel($distortion_im, mt_rand() % $im_x, mt_rand() % $im_y, $randcolor);
     }
     $rand = mt_rand(5, 30);
     $rand1 = mt_rand(15, 25);
     $rand2 = mt_rand(5, 10);
     for ($yy = $rand; $yy <= +$rand + 2; $yy++) {
         for ($px = -80; $px <= 80; $px = $px + 0.1) {
             $x = $px / $rand1;
             if ($x != 0) {
                 $y = sin($x);
             }
             $py = $y * $rand2;
             imagesetpixel($distortion_im, $px + 80, $py + $yy, $text_c);
         }
     }
     //设置文件头;
     Header("Content-type: image/JPEG");
     //以PNG格式将图像输出到浏览器或文件;
     ImagePNG($distortion_im);
     //销毁一图像,释放与image关联的内存;
     ImageDestroy($distortion_im);
     ImageDestroy($im);
 }
开发者ID:nanfs,项目名称:lt,代码行数:60,代码来源:pin.class.php

示例10: create_image

function create_image()
{
    // hash: là mật mã
    $md5_hash = md5(rand(0, 999));
    // rand phat sinh 1 số từ 0 - 999
    // md5 sẽ mã hóa 1 số thành 1 số khác đến 32 ký tự
    $security_code = substr($md5_hash, 15, 4);
    // substr lấy 1 chuỗi con trong md5_hash, lấy từ ký tự thứ 15 và lấy 5 ký tự
    $_SESSION['security_code'] = $security_code;
    $width = 100;
    //Khai báo kích thước captcha
    $height = 30;
    $image = imagecreate($width, $height);
    $while = imagecolorallocate($image, 255, 255, 255);
    $black = imagecolorallocate($image, 0, 0, 0);
    $red = imagecolorallocate($image, 255, 255, 0);
    imagefill($image, 0, 0, $black);
    imagestring($image, 5, 30, 6, $security_code, $while);
    // 5 font size
    // 30 khoảng cách bên trái
    //khoảng cách từ trên xuống
    $captcha = imagecreatefrompng('captcha1.png');
    $font = 'arial.ttf';
    imagettftext($captcha, 23, 6, 20, 38, $black, $font, $security_code);
    header("Content-Type:image/jpeg");
    // chuyển trang web thành dạng hình jpg
    imagejpeg($captcha);
    //Tạo hình
    imagedestroy($captcha);
    // Hủy hình gốc vì đã tạo thành trang
}
开发者ID:tlcn11,项目名称:MaiTranThuy,代码行数:31,代码来源:captcha.php

示例11: __construct

 public function __construct($type = 1, $size = 6)
 {
     Oraculum_Request::init_sess();
     if (is_null(Oraculum_Request::sess("captcha"))) {
         if ($type == 3) {
             $letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
             $max = 61;
         } elseif ($type == 2) {
             $letters = 'abcdefghijklmnopqrstuvwxyz0123456789';
             $max = 35;
         } else {
             $letters = '0123456789';
             $max = 9;
         }
         $string = NULL;
         for ($i = 0; $i < $size; $i++) {
             $string .= $letters[mt_rand(0, $max)];
         }
         Oraculum_Request::setsess("captcha", $string);
     } else {
         $string = Oraculum_Request::sess("captcha");
     }
     $img = imagecreate(10 * $size, 25);
     $backcolor = imagecolorallocate($img, 255, 255, 255);
     $textcolor = imagecolorallocate($img, 00, 00, 00);
     imagefill($img, 0, 0, $backcolor);
     imagestring($img, 10, 0, 5, $string, $textcolor);
     header("Content-type: image/jpeg");
     imagejpeg($img);
 }
开发者ID:RivaldoGuimaraes,项目名称:kap-learning,代码行数:30,代码来源:captcha.php

示例12: _resize_padded

 protected function _resize_padded($canvas_w, $canvas_h, $canvas_color, $width, $height, $orig_w, $orig_h, $origin_x, $origin_y)
 {
     $src_x = $src_y = 0;
     $src_w = $orig_w;
     $src_h = $orig_h;
     $cmp_x = $orig_w / $width;
     $cmp_y = $orig_h / $height;
     // calculate x or y coordinate and width or height of source
     if ($cmp_x > $cmp_y) {
         $src_w = round($orig_w / $cmp_x * $cmp_y);
         $src_x = round(($orig_w - $orig_w / $cmp_x * $cmp_y) / 2);
     } else {
         if ($cmp_y > $cmp_x) {
             $src_h = round($orig_h / $cmp_y * $cmp_x);
             $src_y = round(($orig_h - $orig_h / $cmp_y * $cmp_x) / 2);
         }
     }
     $resized = wp_imagecreatetruecolor($canvas_w, $canvas_h);
     if ($canvas_color === 'transparent') {
         $color = imagecolorallocatealpha($resized, 255, 255, 255, 127);
     } else {
         $rgb = cnColor::rgb2hex2rgb($canvas_color);
         $color = imagecolorallocatealpha($resized, $rgb['red'], $rgb['green'], $rgb['blue'], 0);
     }
     // Fill the background of the new image with allocated color.
     imagefill($resized, 0, 0, $color);
     // Restore transparency.
     imagesavealpha($resized, TRUE);
     imagecopyresampled($resized, $this->image, $origin_x, $origin_y, $src_x, $src_y, $width, $height, $src_w, $src_h);
     if (is_resource($resized)) {
         $this->update_size($width, $height);
         return $resized;
     }
     return new WP_Error('image_resize_error', __('Image resize failed.', 'connections'), $this->file);
 }
开发者ID:VacantFuture,项目名称:Connections,代码行数:35,代码来源:class.gd.php

示例13: execute

 /**
  * Reduces colors of a given image
  *
  * @param  \Intervention\Image\Image $image
  * @return boolean
  */
 public function execute($image)
 {
     $count = $this->argument(0)->value();
     $matte = $this->argument(1)->value();
     // get current image size
     $size = $image->getSize();
     // create empty canvas
     $resource = imagecreatetruecolor($size->width, $size->height);
     // define matte
     if (is_null($matte)) {
         $matte = imagecolorallocatealpha($resource, 255, 255, 255, 127);
     } else {
         $matte = $image->getDriver()->parseColor($matte)->getInt();
     }
     // fill with matte and copy original image
     imagefill($resource, 0, 0, $matte);
     // set transparency
     imagecolortransparent($resource, $matte);
     // copy original image
     imagecopy($resource, $image->getCore(), 0, 0, 0, 0, $size->width, $size->height);
     if (is_numeric($count) && $count <= 256) {
         // decrease colors
         imagetruecolortopalette($resource, true, $count);
     }
     // set new resource
     $image->setCore($resource);
     return true;
 }
开发者ID:shubhomoy,项目名称:evolve,代码行数:34,代码来源:LimitColorsCommand.php

示例14: createCaptcha

 public function createCaptcha()
 {
     $captcha = '';
     $symbol = '0';
     $width = 420;
     $height = 70;
     $font = 'fonts/bellb.ttf';
     $fontsize = 20;
     $captchaLength = rand(1, 1);
     $im = imagecreatetruecolor($width, $height);
     $bg = imagecolorallocatealpha($im, 0, 0, 0, 127);
     imagefill($im, 0, 0, $bg);
     for ($i = 0; $i < $captchaLength; $i++) {
         $captcha .= $symbol[rand(0, strlen($symbol) - 1)];
         $x = ($width - 20) / $captchaLength * $i + 10;
         $x = rand($x, $x + 4);
         $y = $height - ($height - $fontsize) / 2;
         $curcolor = imagecolorallocate($im, rand(0, 100), rand(0, 100), rand(0, 100));
         $angle = rand(-25, 25);
         imagettftext($im, $fontsize, $angle, $x, $y, $curcolor, $font, $captcha[$i]);
     }
     session_start();
     $_SESSION['captcha'] = $captcha;
     header('Content-type: image/png');
     imagepng($im);
     imagedestroy($im);
 }
开发者ID:Arxemond777,项目名称:News,代码行数:27,代码来源:captcha.php

示例15: createBg

 private function createBg()
 {
     $this->img = imagecreatetruecolor($this->width, $this->height);
     $color = imagecolorallocate($this->img, mt_rand(157, 255), mt_rand(157, 255), mt_rand(157, 255));
     //imagefilledrectangle($this->img,0,$this->height,$this->width,0,$color);
     imagefill($this->img, 0, 0, $color);
 }
开发者ID:xiaowei520,项目名称:web_flower,代码行数:7,代码来源:Captcha.php


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