Applies filter to given thumbnail object.

@param \GdThumb $thumb

@return \Intervention\Image\Image
338191
public function applyFilter(GdThumb $thumb)
    {
        $thumb->imageFilter(IMG_FILTER_GRAYSCALE);
        $thumb->imageFilter(IMG_FILTER_BRIGHTNESS, 80);
        $thumb->imageFilter(IMG_FILTER_COLORIZE, -30, -143, -255);

        return $thumb;
    }
1323013
public function thumbnail($type = 'auto')
    {
        if ($type !== 'auto' && !\in_array($type, $this->thumbnailTypes, true)) {
            return $this;
        }

        if ($this->thumbnailType !== $type) {
            $this->_thumbnail = null;
        }

        $this->thumbnailType = $type;

        return $this;
    }
1045173
public function apply($resource){
		if(!function_exists('imagefilter')){
			throw new Exception("It seems your PHP version is not compiled with the bundled version of the GD library");
		}
		// Format
		@list(,$level)=func_get_args();
		$level=(int)$level;
		if($level<-255) $level=-255;
		if($level>255)  $level=255;
		// Apply effect
		if(!imagefilter($resource,IMG_FILTER_BRIGHTNESS,$level)){
			throw new Exception("BRIGHTNESS filter failed");
		}
		return $resource;
	}
704102
public function applyFilter(\Intervention\Image\Image $image)
    {
        $image->pixelate($this->size);
        $image->greyscale();

        return $image;
    }
1374548
public function apply(Picture $picture)
    {
        // GD VERSION IS BETTER AND IS PREFERRED
        if($picture->isGd() || $picture->gdAvailable())
        {
            $resource = $picture->getResource($picture::WORKER_GD);

            imagefilter($resource, IMG_FILTER_EDGEDETECT);

            $picture->setResource($resource);
        }
        else
        {
            $resource = $picture->getResource($picture::WORKER_IMAGICK);
            $resource->convolveImage(array(

                -1,-1,-1,-1,8,-1,-1,-1,-1
            ));
            $resource->thresholdImage(1);
        }
    }
293543
public function apply( $image ) {

        imagefilter($image->getCore(), IMG_FILTER_COLORIZE, $this->red, $this->green, $this->blue);
        return $image;
    }
163813
public static function getMemberPhoto($member, $anonymous=0, $thumbit=true, $serveFile=true)
	{
		static $dfthumb;
		static $dffull;

		$config = \Component::params('com_members');

		// Get the default picture
		// We need to do this here as it may be needed by the Gravatar service
		if (!$dffull)
		{
			$dffull = '/core/components/com_members/site/assets/img/profile.gif'; //ltrim($config->get('defaultpic', '/components/com_members/site/assets/img/profile.gif'), DS);
		}
		if (!$dfthumb)
		{
			if ($thumbit)
			{
				$dfthumb = self::thumbit($dffull);
			}
		}

		// lets make sure we have a profile object
		if ($member instanceof User)
		{
			return $member->picture($anonymous, $thumbit, $serveFile);
		}
		else if (is_numeric($member) || is_string($member))
		{
			$member = Profile::getInstance($member);
		}

		$paths = array();

		$apppath = trim(substr(PATH_APP, strlen(PATH_ROOT)), DS) . '/site/members';

		// If not anonymous
		if (!$anonymous)
		{
			// If we have a member
			if (is_object($member))
			{
				if (!$member->get('picture'))
				{
					// Do we auto-generate a picture?
					if ($config->get('identicon'))
					{
						$path = PATH_APP . DS . trim($config->get('webpath', '/site/members'), DS) . DS . self::niceidformat($member->get('uidNumber'));

						if (!is_dir($path))
						{
							\App::get('filesystem')->makeDirectory($path);
						}

						if (is_dir($path))
						{
							$identicon = new Identicon();

							// Create a profile image
							$imageData = $identicon->getImageData($member->get('email'), 200, $config->get('identicon_color', null));
							file_put_contents($path . DS . 'identicon.png', $imageData);

							// Create a thumbnail image
							$imageData = $identicon->getImageData($member->get('email'), 50, $config->get('identicon_color', null));
							file_put_contents($path . DS . 'identicon_thumb.png', $imageData);

							// Save image to profile
							$member->set('picture', 'identicon.png');
							// Update directly. Using update() method can cause unexpected data loss in some cases.
							$database = \App::get('db');
							$database->setQuery("UPDATE `#__xprofiles` SET picture=" . $database->quote($member->get('picture')) . " WHERE uidNumber=" . $member->get('uidNumber'));
							$database->query();
							//$member->update();
						}
					}
				}

				// If member has a picture set
				if ($member->get('picture'))
				{
					$thumb  = DS . $apppath . DS . self::niceidformat($member->get('uidNumber'));

					$thumbAlt = $thumb . DS . ltrim($member->get('picture'), DS);
					if ($thumbit)
					{
						$thumbAlt = $thumb . DS . 'thumb.png';
					}

					$thumb .= DS . ltrim($member->get('picture'), DS);

					if ($thumbit)
					{
						$thumb = self::thumbit($thumb);
					}

					$paths[] = $thumbAlt;
					$paths[] = $thumb;
				}
				else
				{
					// If use of gravatars is enabled
					if ($config->get('gravatar'))
					{
						$hash = md5(strtolower(trim($member->get('email'))));
						$protocol = \App::get('request')->isSecure() ? 'https' : 'http';

						return $protocol
								. '://www.gravatar.com/avatar/' . htmlspecialchars($hash) . '?'
								. (!$thumbit ? 's=300&' : '')
								. 'd=' . urlencode(str_replace('/administrator', '', rtrim(\App::get('request')->base(), '/')) . '/' . $dfthumb);
					}
				}
			}
		}

		// Add the default picture last
		$paths[] = ($thumbit) ? $dfthumb : $dffull;

		// Start running through paths until we find a valid one
		foreach ($paths as $path)
		{
			if ($path && file_exists(PATH_ROOT . $path))
			{
				if (!$anonymous)
				{
					// build base path (ex. /site/members/12345)
					$baseMemberPath  = DS . $apppath . DS . self::niceidformat($member->get('uidNumber'));

					// if we want to serve file & path is within /site
					if ($serveFile && strpos($path, $baseMemberPath) !== false)
					{
						// get picture name (allows to pics in subfolder)
						$pic = trim(str_replace($baseMemberPath, '', $path), DS);

						// build serve link
						$link = with(new \Hubzero\Content\Moderator(PATH_ROOT . $path))->getUrl();
						return $link;
					}
				}

				return str_replace('/administrator', '', rtrim(\App::get('request')->base(true), '/')) . $path;
			}
		}
	}
628115
public function getThumbnail($obj, $maxWidth, $maxHeight, $crop = false)
    {
        $config = $this->app->make('config');
        if ($config->get('concrete.misc.basic_thumbnailer_generation_strategy') == 'async') {
            return $this->returnThumbnailObjectFromResolver($obj, $maxWidth, $maxHeight, $crop);
        } else {
            return $this->checkForThumbnailAndCreateIfNecessary($obj, $maxWidth, $maxHeight, $crop);
        }
    }
703720
public static function resizeThumbnailImage($thumb_image_name, $image, $width, $height, $start_width, $start_height, $scale)
    {
        $newImageWidth = ceil($width * $scale);
        $newImageHeight = ceil($height * $scale);
        $newImage = imagecreatetruecolor($newImageWidth, $newImageHeight);
        $source = imagecreatefromjpeg($image);
        imagecopyresampled($newImage, $source, 0, 0, $start_width, $start_height, $newImageWidth, $newImageHeight, $width, $height);
        imagejpeg($newImage, $thumb_image_name, 90);
        chmod($thumb_image_name, 0777);

        return $thumb_image_name;
    }
680468
public function create($image, $thumbnailWidth = 100, $thumbnailHeight = 100)
    {
        $this->setupTargetPath($image);
        $this->setupTargetImage($image);

        $this->transformation->thumbnail(new Image\Box($thumbnailWidth, $thumbnailHeight))
                             ->apply($this->imagine->open($image))
                             ->save($this->thumbnailImage);

        $this->imageSize = getimagesize($this->thumbnailImage);
    }
278056
public function apply(Picture $picture)
    {
        $resource = $picture->getResource();

        if($picture->isGd())
        {
            // GIF IMAGES HAS PROBLEM WITH THIS FILTER
            if(strtolower(pathinfo($picture->getImage(), PATHINFO_EXTENSION)) === 'gif')
            {
                return;
            }

            for($i = 0; $i < $this->strength; $i++)
            {
                imagefilter($resource, IMG_FILTER_GAUSSIAN_BLUR);
            }

            $picture->setResource($resource);
        }
        else
        {
            $resource->blurImage(1 * $this->strength, 0.45 * $this->strength);
        }
    }
965445
public function storeTemporaryThumbnail (Thumbnail $thumbnail)
    {
        $json = $this->storeGenericMedia(MediaType::THUMBNAIL, false, $thumbnail);

        return (new Uploaded\Thumbnail($json->thumb_media_id))
            ->withExpiresDate($this->createExpiryDate($json->created_at));
    }
470372
public function thumbnail($media, $format, $options = [])
    {
        return $this->getTwigExtension()->thumbnail($media, $format, $options);
    }
557337
public function apply(ImageInterface $image)
    {
        /** @var \Gmagick $gmagick */
        $gmagick = $image->getGmagick();
        $gmagick->reduceNoiseImage((float)$this->getOption('radius', 0));

        return $image;
    }
1062061
public function thumbize( $width, $height )
	{
		if( !count( $this->size ) )
			throw new RuntimeException( 'No Source Image set.' );

		$thumb	= imagecreatetruecolor( $width, $height );
		if( function_exists( 'imageantialias' ) )
			imageantialias( $thumb, TRUE );

		switch( $this->size[2] )
		{
			case 1:      //GIF
				$source	= imagecreatefromgif( $this->source );
				imagecopyresampled( $thumb, $source, 0, 0, 0, 0, $width, $height, $this->size[0], $this->size[1] );
				imagegif( $thumb, $this->target );
				break;
			case 2:      //JPEG
				$source	= imagecreatefromjpeg( $this->source );
				imagecopyresampled( $thumb, $source, 0, 0, 0, 0, $width, $height, $this->size[0], $this->size[1] );
				imagejpeg( $thumb, $this->target, $this->quality );
				break;
			case 3:      //PNG
				$source	= imagecreatefrompng( $this->source );
				imagecopyresampled( $thumb, $source, 0, 0, 0, 0, $width, $height, $this->size[0], $this->size[1] );
				imagepng( $thumb, $this->target );
				break;
			default:
				throw new Exception( 'Image Type is no supported.' );
		}
		return true;
	}
1363946
public function filter(String $filter, Int $arg1 = NULL, Int $arg2 = NULL, Int $arg3 = NULL, Int $arg4 = NULL) : GD
    {
        $filters = Singleton::class('ZN\DataTypes\Collection')->data(func_get_args())
                                                              ->removeFirst()
                                                              ->deleteElement(NULL)
                                                              ->get();
        
        imagefilter($this->canvas, Helper::toConstant($filter, 'IMG_FILTER_'), ...$filters);

        return $this;
    }
767631
private function thumbUnCut($thumbWidth, $thumbHeight, $quality, $thumbType = 'jpg') 
    {
        list($srcW, $srcH) = $this->imgInfo;
        
        // 宽或高按比例缩放
        if ($thumbWidth == 0 || $thumbHeight == 0) {
            if ($thumbWidth == 0) {
                $thumbHeight = $srcH * ($thumbWidth / $srcW);
            } else {
                $thumbWidth = $thumbWidth = $srcW * ($thumbHeight/$srcH);
            }
            $imgW = $thumbWidth; // 图片显示宽
            $imgH = $thumbHeight; // 图片显示高
            $posX = 0; 
            $posY = 0;
        } else {
            if ($thumbWidth/$thumbHeight < $srcW/$srcH) {
                // 宽比例超过，补上高
                $imgW = $thumbWidth; // 图片显示宽
                $imgH = $thumbWidth * $srcH / $srcW; // 图片显示高
                $posX = 0;
                $posY = ($thumbHeight - $imgH) / 2;
            } else {
                // 高比例超过，补上宽
                $imgH = $thumbHeight; // 图片显示宽
                $imgW = $thumbHeight * $srcW / $srcH; // 图片显示高
                $posX = ($thumbWidth - $imgW) / 2;
                $posY = 0;
            }
        }
        
        $thumbImage = imagecreate($thumbWidth, $thumbHeight);
        
        // 填充背景色
        $fillColor = imagecolorallocate($thumbImage, $this->bgColor[0], $this->bgColor[1], $this->bgColor[2]);
        imagefill($thumbImage, 0, 0, $fillColor);

        // 合上图
        $attachImage = imagecreatefromstring($this->imageContent);
        imagecopyresized($thumbImage, $attachImage, $posX, $posY, 0, 0, $imgW, $imgH, $srcW, $srcH);
        
        // 为兼容云存贮设备，不直接把缩略图写入文件系统，而是返回文件内容
        ob_start();

        if ($thumbType == 'webp') {
            imagewebp($thumbImage, null, $quality);
        } elseif ($thumbType == 'png') {
            imagepng($thumbImage, null, floor($quality/10));
        } else {
            imagejpeg($thumbImage, null, $quality);
        }

        $thumb = ob_get_clean();

        imagedestroy($attachImage);
        imagedestroy($thumbImage);
        
        if(!$thumb) {
            throw new Exception('无法生成缩略图');
        }
        
        return $thumb;
    }