Application du filtre

@param  resource $imageRessource  ImageRessource GD sur lequel appliquer le filtre
@return resource                  ImageRessource GD modifiée
@throws \Exception
979813
public function apply($imageRessource)
  {
    try {
      $imagick = ImagickGd::convertGDRessourceToImagick($imageRessource, Image::IMAGE_TYPE_PNG);
      $imagick->evaluateImage(\Imagick::EVALUATE_MULTIPLY, $this->opacity / 100, \Imagick::CHANNEL_ALPHA);
      $gd = ImagickGd::convertImagickToGDRessource($imagick, Image::IMAGE_TYPE_PNG);
      return $gd;
    } catch (\Exception $e) {
      throw new \Exception('Le filtre Opacity n\'est appliquable que sur des images PNG');
    }
    return null;
  }
367208
public function resize(ImageResource $imageResource) {
		$imageResource->proportionalResize($this->imageDimension->getWidth(), $this->imageDimension->getHeight(),
				$this->getAutoCropMode());
	}
270842
public function applyFilter(Image $image)
    {
        $image->fit($this->params["w"], $this->params["h"]);

        return $image;
    }
867998
public function filter(Url $url, ResolutionInterface $resolution, ResolutionInterface $originalResolution)
    {
        if ($resolution->getResolutionType() == ResolutionType::NOT_FOUND) {
            $parentUrl = $url->sliceSegments(0, -1);

            try {
                $parent = $this->branches->get($parentUrl);

                if ($parent instanceof PostInterface) {
                    /** @var Post $child */
                    foreach ($parent->getChildren() as $child) {
                        if ($child->getUrl()->is($url)) {
                            return new PostResolution($child);
                        }
                    }

                    /** @var File $file */
                    foreach ($parent->getAttachments() as $file) {
                        if ($file->getUrl()->is($url)) {
                            return new FileResolution($file);
                        }
                    }
                }
            } catch (NodeNotFoundException $e) {
                return $originalResolution;
            }
        }

        return $originalResolution;
    }
994279
public function apply($resource){
		// Get resolution
		$width=imagesx($resource);
		$height=imagesy($resource);
		if($width===false || $height===false){
			throw new Exception("An error was encountered while getting image resolution");
		}
		// Image conversion
		$new=imagecreatetruecolor($width,$height);
		if(!imagecopy($new,$resource,0,0,0,0,$width,$height)){
			throw new Exception("An error was encountered while copying image");
		}
		return $new;
	}
618913
public function create() {
        switch($this->info[2]) {
            case IMAGETYPE_JPEG:
                $this->resource = imagecreatefromjpeg($this->file);
                break;
            case IMAGETYPE_GIF:
                $this->resource = imagecreatefromgif($this->file);
                break;
            case IMAGETYPE_PNG:
                $this->resource = imagecreatefrompng($this->file);
                break;
            default:
                throw new Exception('Image type is not supported');
                break;
        }
    }
525043
protected function getImageSource($source, array &$parameter)
    {
        $fragments  = preg_split('%:%', $source, -1, PREG_SPLIT_NO_EMPTY);
        $parameter['source'] = array_shift($fragments);
        $this->parseImageFilter($fragments, $parameter);
    }
777307
public function filter(Url $url, ResolutionInterface $resolution, ResolutionInterface $originalResolution)
    {
        if ($resolution->getResolutionType() === ResolutionType::POST) {
            $post = $resolution->getNode();

            if ($post instanceof Post and !$post instanceof AbstractPost) {
                /** @var File $attachment */
                foreach ($post->getAttachments(true) as $attachment) {
                    if (in_array($attachment->getExtension(), $this->extensions)) {
                        $post->mergeProperties($this->postFileParser->parse($attachment->getPath()));
                        $post->setProperty('__content_filename', $attachment->getUrl()->getLastSegment());

                        break;
                    }
                }
            }
        }

        return $resolution;
    }
14915
protected function _analyzeSourceImage($imageResource, $imageType) {
        $this->_params['sourceWidth'] = imagesx($imageResource);
        $this->_params['sourceHeight'] = imagesy($imageResource);
        $this->_params['mime'] = image_type_to_mime_type($imageType);
        $this->_params['type'] = $imageType;
    }
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;
	}
757876
public function apply($resource){
		// Extract arguments
		@list(,$x,$y,$width,$height)=func_get_args();
		$x=(int)$x;
		$y=(int)$y;
		$width=(int)$width;
		$height=(int)$height;
		// Get resolution
		$w_src=imagesx($resource);
		$h_src=imagesy($resource);
		if($w_src===false || $h_src===false){
			throw new Exception("An error was encountered while getting source image resolution");
		}
		// Verifications
		if(!$width || !$height){
			throw new Exception("Invalid image resolution provided");
		}
		if(($x+$width)>$w_src || ($y+$height)>$h_src){
			throw new Exception("Dimensions provided seems to be out of the image resolution");
		}
		// Create new image
		$image=$this->_createTrueColor($width,$height);
		// Cut image
		if(!imagecopy($image,$resource,0,0,$x,$y,$width,$height)){
			throw new Exception("Failed to copy image portion");
		}
		return $image;
	}
171069
public static function FromImageResource( $imageResource ) : Rectangle
   {

      return new Rectangle(
         new Point(),
         new Size( \imagesx( $imageResource ), \imagesy( $imageResource ) )
      );

   }
1312188
public function setSource( $source )
	{
		if( !file_exists( $source ) )
			throw new InvalidArgumentException( 'Image File "'.$source.'" is not existing.' );
		$size = @getimagesize( $source );
		if( !$size )
			throw new Exception( 'Source File "'.$source.'" is not a supported Image.' );
		$this->size		= $size;
		$this->source	= $source;
	}
791104
private function getImageResource(MediaEntity $media)
    {
        $filePath = $this->urlGenerator->getRelativeMediaUrl($media);
        $file = $this->fileSystem->read($filePath);
        $image = @imagecreatefromstring($file);
        if (!$image) {
            throw new FileTypeNotSupportedException($media->getId());
        }

        return $image;
    }
1080474
public function apply($imageRessource)
  {
    $startWidth = imagesx($imageRessource);
    $startHeight = imagesy($imageRessource);

    $xratio = $startWidth / $this->width;
    $yratio = $startHeight / $this->height;
    if ($xratio == $yratio) {
      if ($startHeight == $this->height && $startWidth == $this->width) {
        return $imageRessource;
      }
      $newWidth  = $this->width;
      $newHeight = $this->height;
    } else if($xratio > $yratio) {
      $newWidth  = $this->width;
      $newHeight = (($startHeight*(($newWidth)/$startWidth)));
    } else {
      $newHeight = $this->height;
      $newWidth  = (($startWidth*(($newHeight)/$startHeight)));
    }

    // Calcul du décalage de l'image
    $xdecay = 0;
    if ($newWidth != $this->width) {
      $xdecay = ($this->width - $newWidth)/2;
    }
    $ydecay = 0;
    if ($newHeight != $this->height) {
      $ydecay = ($this->height - $newHeight)/2;
    }

    $resized = Image::createEmptyContainer($this->width, $this->height, $this->red, $this->green, $this->blue, true);
    imagecopyresampled($resized, $imageRessource, $xdecay, $ydecay, 0, 0, $newWidth, $newHeight, $startWidth, $startHeight);
    imagedestroy($imageRessource);
    return $resized;
  }
1173111
public static function createFromFile( $imageFile ){
        $imageFile = realpath( $imageFile );

        if ( ! file_exists( $imageFile ) ) {
            throw new \Exception( sprintf('Could not open image file "%s"', $imageFile) );
        }

        $imagick = new \Imagick( realpath($imageFile) );
        $animated = false;
        if ($imagick->getImageIterations() > 0) {
            $animated = true;
        }

        return new self(
            $imagick,
            $imageFile,
            $imagick->getImageWidth(),
            $imagick->getImageHeight(),
            $imagick->getImageFormat(),
            $animated
        );
    }
709315
public function apply($imageRessource)
  {
    $width = imagesx($imageRessource);
    $height = imagesy($imageRessource);
    for ($x = 0; $x < $width; $x++) {
      for ($y = 0; $y < $height; $y++) {
        $color = imagecolorallocatealpha($imageRessource, $this->red, $this->green, $this->blue, $this->opacity);
        imagesetpixel($imageRessource, $x, $y, $color);
      }
    }
    return $imageRessource;
  }