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


PHP imagefilter函数代码示例

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


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

示例1: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(array $arguments)
 {
     if ($arguments['level']) {
         return imagefilter($this->getToolkit()->getResource(), IMG_FILTER_BRIGHTNESS, round($arguments['level'] / 100 * 255));
     }
     return TRUE;
 }
开发者ID:andrewl,项目名称:andrewlnet,代码行数:10,代码来源:Brightness.php

示例2: apply

 /**
  * @param Image $image
  *
  * @return Image
  */
 public function apply($image)
 {
     for ($i = 0; $i < $this->amount; $i++) {
         imagefilter($image->getCore(), IMG_FILTER_GAUSSIAN_BLUR);
     }
     return $image;
 }
开发者ID:kosinix,项目名称:grafika,代码行数:12,代码来源:Blur.php

示例3: execute

 public function execute(array $options = array())
 {
     if (!isset($options[IMG_FILTER_CONTRAST]) || !is_int($options[IMG_FILTER_CONTRAST])) {
         throw new InvalidArgumentException('No valid contrast value was given.  Expected integer.');
     }
     imagefilter($this->handle, IMG_FILTER_CONTRAST, $options[IMG_FILTER_CONTRAST]);
 }
开发者ID:ranrolls,项目名称:ras-full-portal,代码行数:7,代码来源:contrast.php

示例4: apply

 public function apply($resource)
 {
     $times = 0;
     while (++$times != $this->settings->strength) {
         imagefilter($resource->image, IMG_FILTER_GAUSSIAN_BLUR);
     }
 }
开发者ID:psychoticmeowArchives,项目名称:Imaje,代码行数:7,代码来源:blur.php

示例5: resize_uploaded_file

function resize_uploaded_file($sIn, $sOut)
{
    $hIn = imagecreatefromjpeg($sIn);
    imagefilter($hIn, IMG_FILTER_CONTRAST, 20);
    list($x, $y, $type, $attr) = getimagesize($sIn);
    if ($x > $y) {
        $nXNew = $y * 260 / 200;
        $nYNew = $y;
        $nXOffs = ($x - $nXNew) / 2;
        $hCanvas = imagecreatetruecolor($nXNew, $y);
        imagecopy($hCanvas, $hIn, 0, 0, $nXOffs, 0, $nXNew, $y);
    } else {
        $nXNew = $x;
        $nYNew = $x * 200 / 260;
        $nYOffs = ($y - $nYNew) / 2;
        $hCanvas = imagecreatetruecolor($x, $nYNew);
        imagecopy($hCanvas, $hIn, 0, 0, 0, $nYOffs, $x, $nYNew);
    }
    $h160x150 = imagecreatetruecolor(260, 200);
    imagecopyresampled($h160x150, $hCanvas, 0, 0, 0, 0, 260, 200, $nXNew, $nYNew);
    $sOutfile = preg_replace('/\\.jpg/i', '_260x200.jpg', $sOut);
    imagejpeg($h160x150, $sOutfile, 100);
    unlink($sIn);
    return $sOutfile;
}
开发者ID:rhildred,项目名称:addCustomer,代码行数:25,代码来源:index.php

示例6: Render

 public function Render()
 {
     $text = $this->GenWord();
     $this->InitImage();
     $this->SetText($text);
     //        $this->WaveImage();
     $this->SetBackground();
     header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
     header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
     header("Cache-Control: no-store, no-cache, must-revalidate");
     header("Cache-Control: post-check=0, pre-check=0", false);
     header("Pragma: no-cache");
     switch ($this->format) {
         case IMG_PNG:
             header("Content-type: image/png");
             if ($this->blur && function_exists('imagefilter')) {
                 imagefilter($this->im, IMG_FILTER_GAUSSIAN_BLUR);
             }
             imagepng($this->im);
             imagedestroy($this->im);
             break;
         default:
             break;
     }
     die;
 }
开发者ID:konteck,项目名称:QXCore,代码行数:26,代码来源:index.php

示例7: execute

 public function execute(array $options = array())
 {
     if (!isset($options[IMG_FILTER_BRIGHTNESS]) || !is_int($options[IMG_FILTER_BRIGHTNESS])) {
         throw new InvalidArgumentException('No valid brightness value was given.  Expected integer.');
     }
     imagefilter($this->handle, IMG_FILTER_BRIGHTNESS, $options[IMG_FILTER_BRIGHTNESS]);
 }
开发者ID:ranrolls,项目名称:ras-full-portal,代码行数:7,代码来源:brightness.php

示例8: negative

 /**
  * {@inheritdoc}
  */
 public function negative()
 {
     if (false === imagefilter($this->ressource, IMG_FILTER_NEGATE)) {
         throw new RuntimeException('GD Failed to negate image');
     }
     return $this;
 }
开发者ID:anillaogi016,项目名称:zend-admin,代码行数:10,代码来源:Effects.php

示例9: _blur

 /**
  * @return Image
  */
 private function _blur()
 {
     for ($i = 0; $i < $this->blur->blurCount; ++$i) {
         imagefilter($this->_imageStruct->image, IMG_FILTER_GAUSSIAN_BLUR);
     }
     return $this->_imageStruct;
 }
开发者ID:umitakkaya,项目名称:ImageStorage,代码行数:10,代码来源:Blur.php

示例10: getImage

 public function getImage()
 {
     $ini = microtime(true);
     /** Initialization */
     $this->ImageAllocate();
     /** Text insertion */
     $text = $this->getRandomText() . ' ' . $this->getRandomText();
     $fontcfg = $this->fonts[array_rand($this->fonts)];
     $this->WriteText($text, $fontcfg);
     JRequest::setvar('com_jobboard_humanv', $text, 'post');
     $app =& JFactory::getApplication();
     $app->getUserStateFromRequest('com_jobboard.humanv', 'com_jobboard_humanv', $text);
     /** Transformations */
     $this->WaveImage();
     if ($this->blur && function_exists('imagefilter')) {
         imagefilter($this->im, IMG_FILTER_GAUSSIAN_BLUR);
     }
     $this->ReduceImage();
     if ($this->debug) {
         imagestring($this->im, 1, 1, $this->height - 8, "{$text} {$fontcfg['font']} " . round((microtime(true) - $ini) * 1000) . "ms", $this->GdFgColor);
     }
     /** Output */
     $this->WriteImage();
     $this->Cleanup();
 }
开发者ID:Rayvid,项目名称:joomla-jobboard,代码行数:25,代码来源:jobboard_human.php

示例11: blur

function blur($gdImageResource, $blurFactor = 3)
{
    // blurFactor has to be an integer
    $blurFactor = round($blurFactor);
    $originalWidth = imagesx($gdImageResource);
    $originalHeight = imagesy($gdImageResource);
    $smallestWidth = ceil($originalWidth * pow(0.5, $blurFactor));
    $smallestHeight = ceil($originalHeight * pow(0.5, $blurFactor));
    // for the first run, the previous image is the original input
    $prevImage = $gdImageResource;
    $prevWidth = $originalWidth;
    $prevHeight = $originalHeight;
    // scale way down and gradually scale back up, blurring all the way
    for ($i = 0; $i < $blurFactor; $i += 1) {
        // determine dimensions of next image
        $nextWidth = $smallestWidth * pow(2, $i);
        $nextHeight = $smallestHeight * pow(2, $i);
        // resize previous image to next size
        $nextImage = imagecreatetruecolor($nextWidth, $nextHeight);
        imagecopyresized($nextImage, $prevImage, 0, 0, 0, 0, $nextWidth, $nextHeight, $prevWidth, $prevHeight);
        // apply blur filter
        imagefilter($nextImage, IMG_FILTER_GAUSSIAN_BLUR);
        // now the new image becomes the previous image for the next step
        $prevImage = $nextImage;
        $prevWidth = $nextWidth;
        $prevHeight = $nextHeight;
    }
    // scale back to original size and blur one more time
    imagecopyresized($gdImageResource, $nextImage, 0, 0, 0, 0, $originalWidth, $originalHeight, $nextWidth, $nextHeight);
    imagefilter($gdImageResource, IMG_FILTER_GAUSSIAN_BLUR);
    // clean up
    imagedestroy($prevImage);
    // return result
    return $gdImageResource;
}
开发者ID:rsantellan,项目名称:wordpress-ecommerce,代码行数:35,代码来源:blurred.php

示例12: CreateImage

 public function CreateImage()
 {
     $ini = microtime(true);
     /** Initialization */
     $this->ImageAllocate();
     /** Text insertion */
     $text = $this->GetCaptchaText();
     $fontcfg = $this->fonts[array_rand($this->fonts)];
     $this->WriteText($text, $fontcfg);
     $this->session->put($this->session_var, $text);
     /** Transformations */
     if (!empty($this->lineWidth)) {
         $this->WriteLine();
     }
     $this->WaveImage();
     if ($this->blur && function_exists('imagefilter')) {
         imagefilter($this->im, IMG_FILTER_GAUSSIAN_BLUR);
     }
     $this->ReduceImage();
     if ($this->debug) {
         imagestring($this->im, 1, 1, $this->height - 8, "{$text} {$fontcfg['font']} " . round((microtime(true) - $ini) * 1000) . "ms", $this->GdFgColor);
     }
     /** Output */
     $data = $this->WriteImage();
     $this->Cleanup();
     $headers = [];
     if ($this->imageFormat == 'png') {
         $headers['content-type'] = 'image/png';
     } else {
         $headers['content-type'] = 'image/jpeg';
     }
     return $this->response->make($data, 200, $headers);
 }
开发者ID:wicochandra,项目名称:captcha,代码行数:33,代码来源:Captcha.php

示例13: createImage

 public function createImage()
 {
     $ini = microtime(true);
     $this->imageAllocate();
     $text = $this->randCaptcha;
     if (is_null($text) || empty($text)) {
         $text = $this->getRandCaptcha();
     }
     $fontcfg = $this->fonts[array_rand($this->fonts)];
     $this->writeText($text, $fontcfg);
     $this->randCaptcha = $text;
     if (!empty($this->lineWidth)) {
         $this->WriteLine();
     }
     $this->waveImage();
     if ($this->blur && function_exists('imagefilter')) {
         imagefilter($this->im, IMG_FILTER_GAUSSIAN_BLUR);
     }
     $this->reduceImage();
     if ($this->debug) {
         imagestring($this->im, 1, 1, $this->height - 8, "{$text} {$fontcfg['font']} " . round((microtime(true) - $ini) * 500) . "ms", $this->GdFgColor);
     }
     $this->writeImage();
     $this->cleanup();
 }
开发者ID:brunoblauzius,项目名称:sistema,代码行数:25,代码来源:Captcha.php

示例14: getTextFromImage

function getTextFromImage($file)
{
    $background = imagecreatefromjpeg('background.jpg');
    $image = imagecreatefromstring($file);
    $black = imagecolorallocate($image, 0, 0, 0);
    $min_visible_y = $max_y = imagesy($image);
    $min_visible_x = $max_x = imagesx($image);
    $max_visible_x = $max_visible_y = 0;
    for ($y = 0; $y < $max_y; $y++) {
        for ($x = 0; $x < $max_x; $x++) {
            $pixel = ImageColorAt($image, $x, $y);
            $colors = imagecolorsforindex($image, $pixel);
            $pixel_bg = ImageColorAt($background, $x, $y);
            $colors_bg = imagecolorsforindex($background, $pixel_bg);
            $range = 35;
            if ($colors['red'] + $range > $colors_bg['red'] && $colors['red'] - $range < $colors_bg['red']) {
                imagesetpixel($image, $x, $y, $black);
            } else {
                $min_visible_x = $min_visible_x > $x ? $x : $min_visible_x;
                $max_visible_x = $max_visible_x < $x ? $x : $max_visible_x;
                $min_visible_y = $min_visible_y > $y ? $y : $min_visible_y;
                $max_visible_y = $max_visible_y < $y ? $y : $max_visible_y;
            }
        }
    }
    $image = imagecrop($image, ['x' => $min_visible_x, 'y' => $min_visible_y, 'width' => $max_visible_x, 'height' => $max_visible_y]);
    imagefilter($image, IMG_FILTER_GRAYSCALE);
    $tmpfname = tempnam("/tmp", "OCR");
    imagepng($image, $tmpfname);
    $txt = $ocr->recognize($tmpfname, ['eng'], 3);
    unlink($tmpfname);
    return str_replace("\n", "", $txt);
}
开发者ID:vitormattos,项目名称:ocr-test,代码行数:33,代码来源:index.php

示例15: applyFilter

 function applyFilter(Canvas $canvas)
 {
     $himage = $canvas->getImage();
     if (function_exists('imagefilter')) {
         // If gd is bundled this will work
         imagefilter($himage, IMG_FILTER_GRAYSCALE);
     } else {
         // If not we need to do some enumeration
         $total = imagecolorstotal($himage);
         if ($total > 0) {
             // This works for indexed images but not for truecolor
             for ($i = 0; $i < $total; $i++) {
                 $index = imagecolorsforindex($himage, $i);
                 $avg = ($index["red"] + $index["green"] + $index["blue"]) / 3;
                 $red = $avg;
                 $green = $avg;
                 $blue = $avg;
                 imagecolorset($himage, $i, $red, $green, $blue);
             }
         } else {
             // For truecolor we need to enum it all
             for ($x = 0; $x < imagesx($himage); $x++) {
                 for ($y = 0; $y < imagesy($himage); $y++) {
                     $index = imagecolorat($himage, $x, $y);
                     $avg = (($index & 0xff) + ($index >> 8 & 0xff) + ($index >> 16 & 0xff)) / 3;
                     imagesetpixel($himage, $x, $y, $avg | $avg << 8 | $avg << 16);
                 }
             }
         }
     }
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:31,代码来源:grayscale.php


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