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


PHP imagelayereffect函数代码示例

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


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

示例1: getOverlay

 protected function getOverlay($r, $g, $b)
 {
     extract($this->driver->getTargetSize());
     $image = $this->driver->getResource();
     $overlay = imagecreatetruecolor($width, $height);
     imagealphablending($image, true);
     imagelayereffect($image, IMG_EFFECT_OVERLAY);
     imagefilledrectangle($overlay, 0, 0, $width, $height, imagecolorallocatealpha($overlay, $r, $g, $b, 0));
     imagecopy($image, $overlay, 0, 0, 0, 0, imagesx($overlay), imagesy($overlay));
 }
开发者ID:rulemaker,项目名称:jitimage,代码行数:10,代码来源:GdClrzFilter.php

示例2: ct_colorize_pics

 function ct_colorize_pics($sourcePath, $destPath, $r, $g, $b)
 {
     if (@file_exists($sourcePath) && @is_readable($sourcePath) && @is_dir($sourcePath) && ($handle = @opendir($sourcePath))) {
         while (false !== ($file = @readdir($handle))) {
             $ext = strtolower(JFile::getExt($sourcePath . $file));
             if ($file != "." && $file != ".." && ($ext == 'png' || $ext == 'jpg' || $ext == 'jpeg')) {
                 if ($ext == 'png') {
                     $im = imagecreatefrompng($sourcePath . $file);
                 } else {
                     $im = imagecreatefromjpeg($sourcePath . $file);
                 }
                 // prevent CONEXT updaters from wondering why the background images won't load anymore
                 if (JFactory::getApplication()->getTemplate() == 'CONEXT' && stripos($sourcePath, 'bg_images_source') !== false) {
                     // keep alphablending default
                 } else {
                     // turn off alphablending for images that are not explicetly marked to use in the filename
                     if (stripos($file, '_alphablending') === false) {
                         imagealphablending($im, false);
                     }
                 }
                 imagefilter($im, IMG_FILTER_COLORIZE, intval($r), intval($g), intval($b));
                 imagesavealpha($im, true);
                 if (stripos($file, '_multiply') !== false) {
                     if ($ext == 'png') {
                         $im2 = imagecreatefrompng($sourcePath . $file);
                     } else {
                         $im2 = imagecreatefromjpeg($sourcePath . $file);
                     }
                     imagelayereffect($im2, IMG_EFFECT_OVERLAY);
                     $w = imagesx($im);
                     $h = imagesy($im);
                     imagecopy($im2, $im, 0, 0, 0, 0, $w, $h);
                     imagesavealpha($im2, true);
                     ob_start();
                     imagepng($im2);
                     $c = ob_get_contents();
                     ob_end_clean();
                     JFile::write($destPath . $file, $c);
                     imagedestroy($im);
                     imagedestroy($im2);
                 } else {
                     ob_start();
                     imagepng($im);
                     $c = ob_get_contents();
                     ob_end_clean();
                     JFile::write($destPath . $file, $c);
                     imagedestroy($im);
                 }
             }
         }
     }
 }
开发者ID:stritti,项目名称:tpl_dinkelbaeck-mobil,代码行数:52,代码来源:recolor.php

示例3: CaptchaImages

 function CaptchaImages($code, $width = 145, $height = 35)
 {
     /* select the type of font, must be used in directoy in which script is being called into */
     $this->font = dirname(__FILE__) . '/CALIBRI.TTF';
     $font_size = $height * 0.6;
     $image = @imagecreate($width, $height) or die('Cannot initialize new GD image stream');
     /* set the colours */
     $bgR = mt_rand(0, 255);
     $bgG = mt_rand(0, 255);
     $bgB = mt_rand(0, 255);
     $background_color = imagecolorallocate($image, $bgR, $bgG, $bgB);
     $noise_color = imagecolorallocate($image, abs(100 - $bgR), abs(100 - $bgG), abs(100 - $bgB));
     $text_color = imagecolorallocate($image, abs(255 - $bgR), abs(255 - $bgG), abs(255 - $bgB));
     /* 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);
     }
     /* set random colors */
     $w = imagecolorallocate($image, abs(100 - $bgR), abs(100 - $bgG), abs(100 - $bgB));
     $r = imagecolorallocate($image, abs(100 - $bgR), abs(100 - $bgG), abs(100 - $bgB));
     /* Draw a dashed line, 5 red pixels, 5 white pixels */
     $style = array($r, $r, $r, $r, $r, $w, $w, $w, $w, $w);
     imagesetstyle($image, $style);
     imageline($image, 0, 0, $width, $height, IMG_COLOR_STYLED);
     imageline($image, $width, 0, 0, $height, IMG_COLOR_STYLED);
     /* create random polygon points */
     $values = array(mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $height), mt_rand(0, $width), mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $height), mt_rand(0, $width), mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $height), mt_rand(0, $width), mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $height), mt_rand(0, $width), mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $height), mt_rand(0, $width), mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $height), mt_rand(0, $width));
     /* create Random Colors then set it to $clr */
     $r = abs(100 - mt_rand(0, 255));
     $g = abs(100 - mt_rand(0, 255));
     $b = abs(100 - mt_rand(0, 255));
     $clr = imagecolorallocate($image, $r, $g, $b);
     /* create filled polygon with random points */
     imagefilledpolygon($image, $values, 6, $clr);
     $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');
     /* pretty it */
     imageantialias($image, 100);
     imagealphablending($image, 1);
     imagelayereffect($image, IMG_EFFECT_OVERLAY);
     /* output captcha image to browser */
     header('Content-Type: image/jpeg');
     imagejpeg($image);
     imagedestroy($image);
 }
开发者ID:qcww,项目名称:yh_cms,代码行数:51,代码来源:CaptchaSecurityImages.php

示例4: _blend

 public function _blend($opacity = 1, $fill = 1, $options = array())
 {
     // OVERLAY MODE {
     $destX = ($this->base->getWidth() - $this->top->getWidth()) / 2;
     $destY = ($this->base->getHeight() - $this->top->getHeight()) / 2;
     // This line causes all GD operations to use the overlay algorithm
     // when blending pixels together.
     $baseImg = $this->base->getImage();
     imagelayereffect($baseImg, IMG_EFFECT_OVERLAY);
     // Blend the top image onto the base image.
     imagecopy($baseImg, $this->top->getImage(), $destX, $destY, 0, 0, $this->base->getWidth(), $this->base->getHeight());
     // } OVERLAY
     return $baseImg;
 }
开发者ID:manticorp,项目名称:BlendableImage,代码行数:14,代码来源:Overlay.php

示例5: create_image

function create_image()
{
    global $trips, $scale, $offsetX, $offsetY, $alpha, $name;
    // create image from map_bg.jpg, which was made in TileMill
    $im = imagecreatefromjpeg("map_bg.jpg") or die("Cannot Initialize new GD image stream");
    imagelayereffect($im, IMG_EFFECT_ALPHABLEND);
    // lines are mostly transparent and we want to blend those alphas
    $slow = imagecolorallocatealpha($im, 170, 0, 0, $alpha);
    // red
    $med = imagecolorallocatealpha($im, 255, 244, 50, $alpha);
    // yellow
    $fast = imagecolorallocatealpha($im, 0, 240, 128, $alpha);
    // green
    foreach ($trips as $vehicle) {
        for ($i = 1; $i < count($vehicle); $i++) {
            $val = floatval($vehicle[$i][2]);
            // speed
            if ($val < 10) {
                $color = $slow;
            } else {
                if ($val < 25) {
                    $color = $med;
                } else {
                    $color = $fast;
                }
            }
            // $vehicles[$i][0] is latitude, $vehicles[$i][1] is longitude
            imageline($im, $vehicle[$i - 1][1] * $scale + $offsetX, -(projectLat($vehicle[$i - 1][0]) * $scale - $offsetY), $vehicle[$i][1] * $scale + $offsetX, -(projectLat($vehicle[$i][0]) * $scale - $offsetY), $color);
        }
    }
    // titles, etc. for the Bostonography maps
    $white = imagecolorallocate($im, 255, 255, 255);
    imagettftext($im, 50, 0, 50, 100, $white, "pnbold.otf", "MBTA Bus Speeds");
    imagettftext($im, 20, 0, 50, 150, $white, "pnreg.otf", "The speed of buses on " . date("l, F j, Y") . ",");
    imagettftext($im, 20, 0, 50, 190, $white, "pnreg.otf", "based on 24 hour of real-time location data.");
    imagettftext($im, 20, 0, 50, 250, imagecolorallocate($im, 170, 0, 0), "pnbold.otf", "Red:");
    imagettftext($im, 20, 0, 50, 290, imagecolorallocate($im, 255, 244, 50), "pnbold.otf", "Yellow:");
    imagettftext($im, 20, 0, 50, 330, imagecolorallocate($im, 0, 240, 128), "pnbold.otf", "Green:");
    imagettftext($im, 20, 0, 150, 250, $white, "pnreg.otf", "< 10 mph");
    imagettftext($im, 20, 0, 150, 290, $white, "pnreg.otf", "10 to 25 mph");
    imagettftext($im, 20, 0, 150, 330, $white, "pnreg.otf", "> 25 mph");
    imagettftext($im, 10, 0, 50, 380, $white, "pnreg.otf", "Bostonography.com | Street map data copyright OpenStreetMap.org | MBTA bus data via NextBus");
    // Save image twice
    imagejpeg($im, "archive/yesterday.jpg");
    imagejpeg($im, $name);
    // To just output the image instead, comment out the above two lines and use these two
    //header('Content-Type: image/jpeg');
    //imagejpeg($im);
    imagedestroy($im);
}
开发者ID:JonahKE,项目名称:mbta-bus-speed,代码行数:50,代码来源:image.php

示例6: overlay_original

 public function overlay_original($layerPath, $posX = 0, $posY = 0, $layerX = 0, $layerY = 0, $layerWidth = 0, $layerHeight = 0)
 {
     // Load the new layer
     $draw = new Image($layerPath);
     if (!isset($draw->resource)) {
         return;
     }
     imagelayereffect($this->resource, IMG_EFFECT_OVERLAY);
     // Check default sizes
     if ($layerWidth == 0) {
         $layerWidth = $draw->width;
     }
     if ($layerHeight == 0) {
         $layerHeight = $draw->height;
     }
     // Copy the layer to the image
     imagecopy($this->resource, $draw->resource, $posX, $posY, $layerX, $layerY, $layerWidth, $layerHeight);
 }
开发者ID:SkysteedDevelopment,项目名称:Deity,代码行数:18,代码来源:Image.php

示例7: watermark

 /**
  * @param string $file
  * @param int    $offsetX
  * @param int    $offsetY
  * @param float  $opacity
  *
  * @return static
  * @throws \ManaPHP\Image\Adapter\Exception
  */
 public function watermark($file, $offsetX = 0, $offsetY = 0, $opacity = 1.0)
 {
     $file = $this->alias->resolve($file);
     $maskImageInfo = getimagesize($file);
     $maskWidth = $maskImageInfo[0];
     /** @noinspection MultiAssignmentUsageInspection */
     $maskHeight = $maskImageInfo[1];
     /** @noinspection MultiAssignmentUsageInspection */
     $maskType = $maskImageInfo[2];
     if ($maskType === IMAGETYPE_GIF) {
         $maskImage = imagecreatefromgif($file);
     } elseif ($maskType === IMAGETYPE_JPEG) {
         $maskImage = imagecreatefromjpeg($file);
     } elseif ($maskType === IMAGETYPE_PNG) {
         $maskImage = imagecreatefrompng($file);
     } else {
         throw new GdException('Installed GD does not support such images');
     }
     imagesavealpha($maskImage, true);
     $image = imagecreatetruecolor($this->_width, $this->_height);
     imagealphablending($image, false);
     imagesavealpha($image, true);
     if ($maskType !== IMAGETYPE_PNG) {
         $filedColor = imagecolorallocatealpha($image, 127, 127, 127, (1 - $opacity) * 127);
     } else {
         $filedColor = imagecolorallocate($image, 127, 127, 127);
     }
     imagelayereffect($maskImage, IMG_EFFECT_OVERLAY);
     imagefilledrectangle($maskImage, 0, 0, $maskWidth, $maskHeight, $filedColor);
     imagealphablending($this->_image, true);
     imagecopy($this->_image, $maskImage, $offsetX, $offsetY, 0, 0, $maskWidth, $maskHeight);
     return $this;
 }
开发者ID:manaphp,项目名称:manaphp,代码行数:42,代码来源:Gd.php

示例8: imagecreatetruecolor

<?php

$image = imagecreatetruecolor(180, 30);
$layer = imagelayereffect($image, IMG_EFFECT_REPLACE);
if ($layer) {
    ob_start();
    imagepng($image, null, 9);
    $img = ob_get_contents();
    ob_end_clean();
}
echo md5(base64_encode($img));
开发者ID:badlamer,项目名称:hhvm,代码行数:11,代码来源:imagelayereffect_basic.php

示例9: set

 static function set(&$image, $value, $method)
 {
     if ($method == 'border') {
         //画线粗细
         return imagesetthickness($image, (int) $value);
     }
     if ($method == 'style') {
         //画线风格
         return imagesetstyle($image, (array) $value);
     }
     if ($method == 'brush') {
         //画笔图像
         return imagesetbrush($image, $value);
     }
     if ($method == 'pattern') {
         //填充的贴图 图案
         return imagesettile($image, $value);
     }
     if ($method == 'alias') {
         //抗锯齿
         return imageantialias($image, (bool) $value);
     }
     if ($method == 'alpha') {
         //alpha混色标志
         return imagelayereffect($image, (int) $value);
     }
     if ($method == 'transparent') {
         //透明色
         return imagecolortransparent($image, (int) $value);
     }
     if ($method == 'mix') {
         //混色模式
         return imagealphablending($image, (bool) $value);
     }
 }
开发者ID:art-youth,项目名称:framework,代码行数:35,代码来源:img.php

示例10: _do_watermark

 protected function _do_watermark(Image $watermark, $offset_x, $offset_y, $opacity)
 {
     if (!Image_GD::$_bundled) {
         throw new Kohana_Exception('This method requires :function, which is only available in the bundled version of GD', array(':function' => 'imagelayereffect'));
     }
     // Loads image if not yet loaded
     $this->_load_image();
     // Create the watermark image resource
     $overlay = imagecreatefromstring($watermark->render());
     // Get the width and height of the watermark
     $width = imagesx($overlay);
     $height = imagesy($overlay);
     if ($opacity < 100) {
         // Convert an opacity range of 0-100 to 127-0
         $opacity = round(abs($opacity * 127 / 100 - 127));
         // Allocate transparent white
         $color = imagecolorallocatealpha($overlay, 255, 255, 255, $opacity);
         // The transparent image will overlay the watermark
         imagelayereffect($overlay, IMG_EFFECT_OVERLAY);
         // Fill the background with transparent white
         imagefilledrectangle($overlay, 0, 0, $width, $height, $color);
     }
     // Alpha blending must be enabled on the background!
     imagealphablending($this->_image, TRUE);
     if (imagecopy($this->_image, $overlay, $offset_x, $offset_y, 0, 0, $width, $height)) {
         // Destroy the overlay image
         imagedestroy($overlay);
     }
 }
开发者ID:homm,项目名称:image,代码行数:29,代码来源:gd.php

示例11: doApply

 /**
  * {@inheritdoc}
  */
 protected function doApply(CanvasInterface $canvas)
 {
     $box = is_null($this->getBox()) ? new Box($canvas->getDimension()) : $this->getBox();
     $compine = new \Jaguar\Canvas($canvas->getDimension());
     $compine->paste($canvas);
     $compine->paste($this->getOverlay(), null, $box);
     imagelayereffect($canvas->getHandler(), IMG_EFFECT_OVERLAY);
     imagecopymerge($canvas->getHandler(), $compine->getHandler(), 0, 0, 0, 0, $canvas->getWidth(), $canvas->getHeight(), $this->getAmount());
     $canvas->alphaBlending(true);
     $compine->destroy();
 }
开发者ID:El-Loco-Pinguino,项目名称:FaitesUnVoeu_WF3,代码行数:14,代码来源:Overlay.php

示例12: imagecreatefrompng

// add all the icons to the sprite image
for ($i = 0; $i < $cnt; $i++) {
    $base = $i * 90;
    $IN = imagecreatefrompng($input[$i]);
    imagesavealpha($IN, true);
    imagecolorscale($IN, $GAMMA);
    imagecopy($DST, $IN, 0, $base, 0, 0, 30, 30);
    imagedestroy($IN);
    $IN = imagecreatefrompng($input[$i]);
    imagesavealpha($IN, true);
    imagecolorscale($IN, $GAMMA);
    imagecopy($DST, $IN, 0, $base + 45, 0, 0, 30, 30);
    imagedestroy($IN);
    imagelayereffect($DST, IMG_EFFECT_OVERLAY);
    imagefilledrectangle($DST, 0, $base + 45, 30, $base + 45 + 30, $C_active);
    imagelayereffect($DST, IMG_EFFECT_NORMAL);
}
// output sprite
imagepng($DST, 'pagetools-sprite.png');
imagedestroy($DST);
// optimize if possible
if (is_executable($OPTIPNG)) {
    system("{$OPTIPNG} -o5 'pagetools-sprite.png'");
}
/**
 * Convert a hex color code to an rgb array
 */
function hex2rgb($hex)
{
    // strip hash
    $hex = str_replace('#', '', $hex);
开发者ID:omusico,项目名称:isle-web-framework,代码行数:31,代码来源:pagetools-build.php

示例13: layerEffect

 public function layerEffect(string $effect = 'normal') : InternalGD
 {
     imagelayereffect($this->canvas, Converter::toConstant($effect, 'IMG_EFFECT_'));
     return $this;
 }
开发者ID:znframework,项目名称:znframework,代码行数:5,代码来源:InternalGD.php

示例14: watermark

 /**
  * {@inheritdoc}
  */
 public function watermark($file, $position = Image::WATERMARK_TOP_LEFT, $opacity = 100)
 {
     $watermark = $this->createImageResource($file, $this->getImageInfo($file));
     $watermarkWidth = imagesx($watermark);
     $watermarkHeight = imagesy($watermark);
     if ($opacity < 100) {
         // Convert alpha to 0-127
         $alpha = min(round(abs($opacity * 127 / 100 - 127)), 127);
         $transparent = imagecolorallocatealpha($watermark, 0, 0, 0, $alpha);
         imagelayereffect($watermark, IMG_EFFECT_OVERLAY);
         imagefilledrectangle($watermark, 0, 0, $watermarkWidth, $watermarkHeight, $transparent);
     }
     // Position the watermark.
     switch ($position) {
         case Image::WATERMARK_TOP_RIGHT:
             $x = imagesx($this->image) - $watermarkWidth;
             $y = 0;
             break;
         case Image::WATERMARK_BOTTOM_LEFT:
             $x = 0;
             $y = imagesy($this->image) - $watermarkHeight;
             break;
         case Image::WATERMARK_BOTTOM_RIGHT:
             $x = imagesx($this->image) - $watermarkWidth;
             $y = imagesy($this->image) - $watermarkHeight;
             break;
         case Image::WATERMARK_CENTER:
             $x = imagesx($this->image) / 2 - $watermarkWidth / 2;
             $y = imagesy($this->image) / 2 - $watermarkHeight / 2;
             break;
         default:
             $x = 0;
             $y = 0;
     }
     imagealphablending($this->image, true);
     imagecopy($this->image, $watermark, $x, $y, 0, 0, $watermarkWidth, $watermarkHeight);
     imagedestroy($watermark);
 }
开发者ID:muhammetardayildiz,项目名称:framework,代码行数:41,代码来源:GD.php

示例15: set

 static function set(&$image, $value, $style = 'mix')
 {
     switch ($style) {
         case 'border':
             //画线粗细
             return imagesetthickness($image, (int) $value);
         case 'style':
             //画线风格
             return imagesetstyle($image, (array) $value);
         case 'brush':
             //画笔图像
             return imagesetbrush($image, $value);
         case 'pattern':
             //填充的贴图 图案
             return imagesettile($image, $value);
         case 'alias':
             //抗锯齿
             return imageantialias($image, (bool) $value);
         case 'alpha':
             //alpha混色标志
             return imagelayereffect($image, (int) $value);
         case 'transparent':
             //透明色
             return imagecolortransparent($image, (int) $value);
         case 'mix':
             //混色模式
         //混色模式
         default:
             return imagealphablending($image, (bool) $value);
     }
 }
开发者ID:mjiong,项目名称:framework,代码行数:31,代码来源:image.php


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