Application du filtre

@param  resource $imageRessource  ImageRessource GD sur lequel appliquer le filtre
@return resource                  ImageRessource GD modifiée
512174
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;
    }

    $resized = Image::createEmptyContainer($newWidth, $newHeight);
    imagecopyresampled($resized, $imageRessource, 0, 0, 0, 0, $newWidth, $newHeight, $startWidth, $startHeight);
    imagedestroy($imageRessource);
    return $resized;
  }
517885
public function apply($resource){
		// Extract arguments
		@list(,$level)=func_get_args();
		$level=abs((int)$level);
		if(!$level){
		    $level=5;
		}
		// Get resolution
		$width=imagesx($resource);
		$height=imagesy($resource);
		if(!$width || !$height){
			throw new Exception("An error was encountered while getting image resolution");
		}
		// Apply effect
		$x=0;
		do{
			$y=0;
			do{
				// Get current pixel color
				list($r,$g,$b,$a)=$this->_getColorAt($resource,$x,$y);
				// Generate noise
				$z=rand(-$level,$level);
				// Define color
				$r+=$z;
				$g+=$z;
				$b+=$z;
				if($r<0)		$r=0;
				elseif($r>255)	$r=255;
				if($g<0)		$g=0;
				elseif($g>255)	$g=255;
				if($b<0)		$b=0;
				elseif($b>255)	$b=255;
				// Define new pixel
				imagesetpixel($resource,$x,$y,imagecolorallocatealpha($resource,$r,$g,$b,$a));
			}
			while(++$y<$height);
		}
		while(++$x<$width);
		return $resource;
	}
1324263
private function gd_apply_overlay($im, $type, $amount)
		#
		# Original Author:    Marc Hibbins
		# License:  Attribution-ShareAlike 3.0
		# Purpose:
		# Params in:
		# Params out:
		# Notes:
		#
	{
		$width = imagesx($im);
		$height = imagesy($im);
		$filter = imagecreatetruecolor($width, $height);

		imagealphablending($filter, false);
		imagesavealpha($filter, true);

		$transparent = imagecolorallocatealpha($filter, 255, 255, 255, 127);
		imagefilledrectangle($filter, 0, 0, $width, $height, $transparent);

		// *** Resize overlay
		$overlay = $this->filterOverlayPath . '/' . $type . '.png';
		$png = imagecreatefrompng($overlay);
		imagecopyresampled($filter, $png, 0, 0, 0, 0, $width, $height, imagesx($png), imagesy($png));

		$comp = imagecreatetruecolor($width, $height);
		imagecopy($comp, $im, 0, 0, 0, 0, $width, $height);
		imagecopy($comp, $filter, 0, 0, 0, 0, $width, $height);
		imagecopymerge($im, $comp, 0, 0, 0, 0, $width, $height, $amount);

		imagedestroy($comp);

		return $im;
	}
486292
public function setImageResource($value = null)
    {
        $this->imageResource = $value;

        if (!is_null($this->imageResource)) {
            // Get width/height
            $this->width  = imagesx($this->imageResource);
            $this->height = imagesy($this->imageResource);
        }
        return $this;
    }
691249
public function setImageResource($value = null) {
    	$this->_imageResource = $value;

    	if (!is_null($this->_imageResource)) {
	    	// Get width/height
	    	$this->_width	= imagesx($this->_imageResource);
	    	$this->_height	= imagesy($this->_imageResource);
    	}
    	return $this;
    }
602609
protected function applyFilters()
  {
    if ($this->emptyRessource) {
      $source = $this->emptyRessource;
    } else if ($this->extension == self::IMAGE_TYPE_JPG) {
      $source = imagecreatefromjpeg($this->path);
    } else if ($this->extension == self::IMAGE_TYPE_PNG) {
      $source = imagecreatefrompng($this->path);
      imagealphablending($source, false);
      imagesavealpha($source, true);
    }
    foreach($this->filters as $filtre) {
      $source = $filtre->apply($source);
    }
    $this->buildedRessource = $source;
    return $source;
  }
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;
  }
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;
  }
726972
public function addFilter(FilterInterface $filter)
    {
        if (! ($this->resource instanceof ImageFilterableInterface)) {
            throw new UnsupportedMethodException("This method is not supported by the ImageResource in use.");
        }

        $this->getFilterResolver()->addFilter($filter);

        return $this;
    }
1195216
public function setResource(ImageResourceInterface $resource)
    {
        $this->resource = $resource;

        if ($this->resource instanceof ImageFilterableInterface) {
            $this->filterResolver = new FilterResolver($this->resource->loadFilters());
        }
    }
541327
public function setImageUrl($imageUrl)
    {
        $this->style    = null;
        $this->subStyle = null;
        $this->imageUrl = (string)$imageUrl;
        return $this;
    }
1325316
public function getFileSourceMediaId(): \Psr\Http\Message\UriInterface
    {
        if (!$this->fileSourceMediaId) {
            return new Uri();
        }

        return $this->fileSourceMediaId;
    }
881592
public function matches(ImageSource $imageSource): bool {
		if ($this->imageDimension->getWidth() == $imageSource->getWidth()
				&& $this->imageDimension->getHeight() == $imageSource->getHeight()) {
			return true;
		}

		if ($this->scaleUpAllowed) return false;

		return $this->imageDimension->getWidth() >= $imageSource->getWidth()
				&& $this->imageDimension->getHeight() >= $imageSource->getHeight();
	}
672959
public function apply($imageRessource)
  {
    if ($this->gdResource) {
      $source = $this->gdResource;
      $w = imagesx($this->gdResource);
      $h = imagesy($this->gdResource);
    } else {
      $source = $this->imagePasted->getImageRessource();
      $w = $this->imagePasted->getWidth();
      $h = $this->imagePasted->getHeight();
    }
    imagecopymerge($imageRessource, $source, $this->x, $this->y, 0, 0, $w, $h, 100);
    return $imageRessource;
  }
993809
public function cropTransparentImage($imageResource)
    {
        /** @var int $imageTransparency Transparent color */
        $imageTransparency = imagecolorallocatealpha($imageResource, 255, 255, 255, 127);
        /** @var resource $croppedImage Cropped image resource */
        $croppedImage = imagecreatetruecolor($_POST['crop_width'], $_POST['crop_height']);
        // Fill new image with transparent color
        imagefill($croppedImage, 0, 0, $imageTransparency);
        // Save Alpha chanel
        imagesavealpha($croppedImage, true);
        /** @var resource $rotatedImage Rotated image resource */
        $rotatedImage = imagerotate($imageResource, -($_POST['rotate']), $imageTransparency);
        // Copy rotated image to cropped one
        imagecopy(
            $croppedImage,
            $rotatedImage,
            0,
            0,
            $_POST['crop_x'],
            $_POST['crop_y'],
            $_POST['crop_width'],
            $_POST['crop_height']
        );
        // Delete temp image resource
        imagedestroy($rotatedImage);
        // Return result image
        return $croppedImage;
    }
144645
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");
		}
		@list(,$level)=func_get_args();
		if(!imagefilter($resource,IMG_FILTER_CONTRAST,(int)$level)){
			throw new Exception("CONTRAST filter failed");
		}
		return $resource;
	}
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;
    }