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


PHP ImageFilter函数代码示例

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


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

示例1: Smooth

 public function Smooth(&$gdimg, $amount = 6)
 {
     $amount = min(25, max(0, $amount));
     if ($amount == 0) {
         return true;
     }
     if (phpthumb_functions::version_compare_replacement(phpversion(), '5.0.0', '>=') && phpthumb_functions::gd_is_bundled()) {
         if (ImageFilter($gdimg, IMG_FILTER_SMOOTH, $amount)) {
             return true;
         }
         $this->DebugMessage('FAILED: ImageFilter($gdimg, IMG_FILTER_SMOOTH, ' . $amount . ')', __FILE__, __LINE__);
         // fall through and try it the hard way
     }
     // currently not implemented "the hard way"
     $this->DebugMessage('FAILED: phpthumb_filters::Smooth($gdimg, ' . $amount . ') [function not implemented]', __FILE__, __LINE__);
     return false;
 }
开发者ID:exside,项目名称:phpThumb,代码行数:17,代码来源:phpthumb.filters.php

示例2: applyUnsharpMask

 function applyUnsharpMask(&$img, $amount, $radius, $threshold)
 {
     // $img is an image that is already created within php using
     // imgcreatetruecolor. No url! $img must be a truecolor image.
     // Attempt to calibrate the parameters to Photoshop:
     $amount = min($amount, 500);
     $amount = $amount * 0.016;
     if ($amount == 0) {
         return true;
     }
     $radius = min($radius, 50);
     $radius = $radius * 2;
     $threshold = min($threshold, 255);
     $radius = abs(round($radius));
     // Only integers make sense.
     if ($radius == 0) {
         return true;
     }
     $w = ImageSX($img);
     $h = ImageSY($img);
     $imgCanvas = ImageCreateTrueColor($w, $h);
     $imgCanvas2 = ImageCreateTrueColor($w, $h);
     ImageCopy($imgCanvas, $img, 0, 0, 0, 0, $w, $h);
     ImageCopy($imgCanvas2, $img, 0, 0, 0, 0, $w, $h);
     $builtinFilterSucceeded = false;
     if ($radius == 1) {
         if (phpthumb_functions::version_compare_replacement(phpversion(), '5.0.0', '>=') && phpthumb_functions::gd_is_bundled()) {
             if (ImageFilter($imgCanvas, IMG_FILTER_GAUSSIAN_BLUR) && ImageFilter($imgCanvas2, IMG_FILTER_GAUSSIAN_BLUR)) {
                 $builtinFilterSucceeded = true;
             }
         }
     }
     if (!$builtinFilterSucceeded) {
         $imgBlur = ImageCreateTrueColor($w, $h);
         $imgBlur2 = ImageCreateTrueColor($w, $h);
         ///////////////////////////
         //
         // Gaussian blur matrix:
         //	1  2  1
         //	2  4  2
         //	1  2  1
         //
         ///////////////////////////
         // Move copies of the image around one pixel at the time and merge them with weight
         // according to the matrix. The same matrix is simply repeated for higher radii.
         for ($i = 0; $i < $radius; $i++) {
             ImageCopy($imgBlur, $imgCanvas, 0, 0, 1, 1, $w - 1, $h - 1);
             // up left
             ImageCopyMerge($imgBlur, $imgCanvas, 1, 1, 0, 0, $w, $h, 50);
             // down right
             ImageCopyMerge($imgBlur, $imgCanvas, 0, 1, 1, 0, $w - 1, $h, 33.33333);
             // down left
             ImageCopyMerge($imgBlur, $imgCanvas, 1, 0, 0, 1, $w, $h - 1, 25);
             // up right
             ImageCopyMerge($imgBlur, $imgCanvas, 0, 0, 1, 0, $w - 1, $h, 33.33333);
             // left
             ImageCopyMerge($imgBlur, $imgCanvas, 1, 0, 0, 0, $w, $h, 25);
             // right
             ImageCopyMerge($imgBlur, $imgCanvas, 0, 0, 0, 1, $w, $h - 1, 20);
             // up
             ImageCopyMerge($imgBlur, $imgCanvas, 0, 1, 0, 0, $w, $h, 16.666667);
             // down
             ImageCopyMerge($imgBlur, $imgCanvas, 0, 0, 0, 0, $w, $h, 50);
             // center
             ImageCopy($imgCanvas, $imgBlur, 0, 0, 0, 0, $w, $h);
             // During the loop above the blurred copy darkens, possibly due to a roundoff
             // error. Therefore the sharp picture has to go through the same loop to
             // produce a similar image for comparison. This is not a good thing, as processing
             // time increases heavily.
             ImageCopy($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h);
             ImageCopyMerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 50);
             ImageCopyMerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 33.33333);
             ImageCopyMerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 25);
             ImageCopyMerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 33.33333);
             ImageCopyMerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 25);
             ImageCopyMerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 20);
             ImageCopyMerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 16.666667);
             ImageCopyMerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 50);
             ImageCopy($imgCanvas2, $imgBlur2, 0, 0, 0, 0, $w, $h);
         }
         ImageDestroy($imgBlur);
         ImageDestroy($imgBlur2);
     }
     // Calculate the difference between the blurred pixels and the original
     // and set the pixels
     for ($x = 0; $x < $w; $x++) {
         // each row
         for ($y = 0; $y < $h; $y++) {
             // each pixel
             $rgbOrig = ImageColorAt($imgCanvas2, $x, $y);
             $rOrig = $rgbOrig >> 16 & 0xff;
             $gOrig = $rgbOrig >> 8 & 0xff;
             $bOrig = $rgbOrig & 0xff;
             $rgbBlur = ImageColorAt($imgCanvas, $x, $y);
             $rBlur = $rgbBlur >> 16 & 0xff;
             $gBlur = $rgbBlur >> 8 & 0xff;
             $bBlur = $rgbBlur & 0xff;
             // When the masked pixels differ less from the original
             // than the threshold specifies, they are set to their original value.
             $rNew = abs($rOrig - $rBlur) >= $threshold ? max(0, min(255, $amount * ($rOrig - $rBlur) + $rOrig)) : $rOrig;
//.........这里部分代码省略.........
开发者ID:banumelody,项目名称:slims7_cendana,代码行数:101,代码来源:phpthumb.unsharp.php

示例3: brightness_gd

 /**
  * increase or decrease the brightness of an image useing GD library;
  * @param string $filename to the source file
  * @param string $direction  increase or decrease;
  * @return nothing;
  * @access private
  */
 function brightness_gd($filename, $direction)
 {
     if (substr(PHP_VERSION, 0, 1) < 5) {
         return false;
     }
     if (!function_exists('imagefilter')) {
         return false;
     }
     if (!$this->gdInfo >= 1 || !$this->checkGdFileType($filename)) {
         return false;
     }
     $srcImage =& $this->getImg($filename);
     if ($this->hasError()) {
         return false;
     }
     if (strtolower($direction) == 'decrease') {
         $arg = -6;
     } else {
         $arg = 6;
     }
     ImageFilter($srcImage, IMG_FILTER_BRIGHTNESS, $arg);
     $this->createNewImg($srcImage, $filename, $this->qualityLevel);
     return true;
 }
开发者ID:rcardenass,项目名称:Escuela,代码行数:31,代码来源:KT_Image.class.php

示例4: ApplyFilters


//.........这里部分代码省略.........
                     break;
                 case 'fram':
                     // Frame
                     @(list($frame_width, $edge_width, $color_frame, $color1, $color2) = explode('|', $parameter, 5));
                     $phpthumbFilters->Frame($this->gdimg_output, $frame_width, $edge_width, $color_frame, $color1, $color2);
                     break;
                 case 'drop':
                     // DropShadow
                     if (phpthumb_functions::gd_version() < 2) {
                         $this->DebugMessage('Skipping DropShadow() because gd_version is "' . phpthumb_functions::gd_version() . '"', __FILE__, __LINE__);
                         return false;
                     }
                     $this->is_alpha = true;
                     @(list($distance, $width, $color, $angle, $fade) = explode('|', $parameter, 5));
                     $phpthumbFilters->DropShadow($this->gdimg_output, $distance, $width, $color, $angle, $fade);
                     break;
                 case 'mask':
                     // Mask cropping
                     if (phpthumb_functions::gd_version() < 2) {
                         $this->DebugMessage('Skipping Mask() because gd_version is "' . phpthumb_functions::gd_version() . '"', __FILE__, __LINE__);
                         return false;
                     }
                     @(list($mask_filename, $invert) = explode('|', $parameter, 2));
                     $mask_filename = $this->ResolveFilenameToAbsolute($mask_filename);
                     if (@is_readable($mask_filename) && ($fp_mask = @fopen($mask_filename, 'rb'))) {
                         $MaskImageData = '';
                         do {
                             $buffer = fread($fp_mask, 8192);
                             $MaskImageData .= $buffer;
                         } while (strlen($buffer) > 0);
                         fclose($fp_mask);
                         if ($gdimg_mask = $this->ImageCreateFromStringReplacement($MaskImageData)) {
                             if ($invert && phpthumb_functions::version_compare_replacement(phpversion(), '5.0.0', '>=') && phpthumb_functions::gd_is_bundled()) {
                                 ImageFilter($gdimg_mask, IMG_FILTER_NEGATE);
                             }
                             $this->is_alpha = true;
                             $phpthumbFilters->ApplyMask($gdimg_mask, $this->gdimg_output);
                             ImageDestroy($gdimg_mask);
                         } else {
                             $this->DebugMessage('ImageCreateFromStringReplacement() failed for "' . $mask_filename . '"', __FILE__, __LINE__);
                         }
                     } else {
                         $this->DebugMessage('Cannot open mask file "' . $mask_filename . '"', __FILE__, __LINE__);
                     }
                     break;
                 case 'elip':
                     // Elipse cropping
                     if (phpthumb_functions::gd_version() < 2) {
                         $this->DebugMessage('Skipping Elipse() because gd_version is "' . phpthumb_functions::gd_version() . '"', __FILE__, __LINE__);
                         return false;
                     }
                     $this->is_alpha = true;
                     $phpthumbFilters->Elipse($this->gdimg_output);
                     break;
                 case 'ric':
                     // RoundedImageCorners
                     if (phpthumb_functions::gd_version() < 2) {
                         $this->DebugMessage('Skipping RoundedImageCorners() because gd_version is "' . phpthumb_functions::gd_version() . '"', __FILE__, __LINE__);
                         return false;
                     }
                     @(list($radius_x, $radius_y) = explode('|', $parameter, 2));
                     if ($radius_x < 1 || $radius_y < 1) {
                         $this->DebugMessage('Skipping RoundedImageCorners(' . $radius_x . ', ' . $radius_y . ') because x/y radius is less than 1', __FILE__, __LINE__);
                         break;
                     }
                     $this->is_alpha = true;
开发者ID:araranga,项目名称:homan,代码行数:67,代码来源:phpthumb.class.php

示例5: Negate_Image

 function Negate_Image()
 {
     if (!ImageFilter($this->image, IMG_FILTER_NEGATE)) {
         return False;
     } else {
         return True;
     }
 }
开发者ID:RichyVN,项目名称:RST-Intranet,代码行数:8,代码来源:wp-thumb.php


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