Application du filtre

@param  resource $imageRessource  ImageRessource GD sur lequel appliquer le filtre
@return resource                  ImageRessource GD modifiée
161882
public function apply($imageRessource)
  {
    $startWidth = imagesx($imageRessource);
    $startHeight = imagesy($imageRessource);

    $yratio = $startHeight / $this->height;

    $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;
  }
730850
public function resolveFilterFactory($resource, array $parameters = [], $version = null)
    {
        try {
            return $this->resolve('filterFactory', $resource, $parameters, $version);
        } catch (ResourceNotDefinedException $e) {
            return $this->app->make(ArrayFilterFactory::class, $parameters);
        }
    }
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;
  }
985963
public function apply($resource){
		// Extract arguments
		@list(,$rplus,$gplus,$bplus)=func_get_args();
		$rplus=(int)$rplus;
		$gplus=(int)$gplus;
		$bplus=(int)$bplus;
		// 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);
				// Define new color
				$b=$r+$bplus;
				$g=$r+$gplus;
				$r+=$rplus;
				// Format
				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 pixel
				imagesetpixel($resource,$x,$y,imagecolorallocatealpha($resource,$r,$g,$b,$a));
			}
			while(++$y<$height);
		}
		while(++$x<$width);
		return $resource;
	}
569533
private static function getCacheDir($imageFile) {
    $mediaRoot = self::getMediaRootRelative();
    return self::getCacheRoot().dirname(substr($imageFile, strlen($mediaRoot))).'/';
  }
139691
public function hydrateResource($source): ResourceObject
    {
        if (! isset($source->id)) {
            throw new InvalidDocumentException('Resource contains no ID');
        }

        if (! isset($source->type)) {
            throw new InvalidDocumentException('Resource contains no type');
        }

        $attributes = empty($source->attributes) ? [] : get_object_vars($source->attributes);

        $resource = new ResourceObject($source->id, $source->type, $attributes);

        $this->hydrateObject($resource, $source);

        return $resource;
    }
1211500
public function getFilter($index)
    {
        if (!$this->hasFilter($index)) {
            throw new \Exception('Impossible de trouver le filtre : ' . $index);
        }

        return $this->filters[$index];
    }
1325316
public function getFileSourceMediaId(): \Psr\Http\Message\UriInterface
    {
        if (!$this->fileSourceMediaId) {
            return new Uri();
        }

        return $this->fileSourceMediaId;
    }
771763
public function createImageResource($keepHandleAlive = false): ImageResource {
		$resource = IoUtils::imageCreateFromPng($this->filePath);
		
		imagealphablending($resource, false);
		
		return new ImageResource($resource, $keepHandleAlive);
	}
1205855
private function getResource()
    {
        if ($this->mime == 'image/gif') {
            return imagecreatefromgif($this->source);
        }
        elseif ($this->mime == 'image/jpg' || $this->mime == 'image/jpeg') {
            return imagecreatefromjpeg($this->source);
        }
        elseif ($this->mime == 'image/png') {
            return imagecreatefrompng($this->source);
        }
        else
            return null;

    }
823518
private function createImageResource()
    {
        // In case of failure, image will be false

        $mimeType = $this->getMimeTypeOfSource();

        if ($mimeType == 'image/png') {
            $image = imagecreatefrompng($this->source);
            if ($image === false) {
                throw new ConversionFailedException(
                    'Gd failed when trying to load/create image (imagecreatefrompng() failed)'
                );
            }
            return $image;
        }

        if ($mimeType == 'image/jpeg') {
            $image = imagecreatefromjpeg($this->source);
            if ($image === false) {
                throw new ConversionFailedException(
                    'Gd failed when trying to load/create image (imagecreatefromjpeg() failed)'
                );
            }
            return $image;
        }

        /*
        throw new InvalidInputException(
            'Unsupported mime type:' . $mimeType
        );*/
    }
1053522
public function apply($resource){
		// Format
		@list(,$level)=func_get_args();
		$level=abs((int)$level);
		if(!$level){
			$level=1;
		}
		// Get resolution
		$width=imagesx($resource);
		$height=imagesy($resource);
		if($width===false || $height===false){
			throw new Exception("An error was encountered while getting image resolution");
		}
		// Loop over all pixels
		$x=0;
		do{
			$y=0;
			do{
				// Generate a position
				$newx=$x+rand(-$level,$level);
				$newy=$y+rand(-$level,$level);
				// Verify that we're not out of bounds
				if($newx>=0 && $newx<$width && $newy>=0 && $newy<$height){
					// Interchange both pixels
					$color=imagecolorat($resource,$x,$y);
					imagesetpixel($resource,$x,$y,imagecolorat($resource,$newx,$newy));
					imagesetpixel($resource,$newx,$newy,$color);
				}
			}
			while(++$y<$height);
		}
		while(++$x<$width);
		return $resource;
	}
1226508
public function imagecolorallocatealpha($imageResource)
	{
		return imagecolorallocatealpha(
			$imageResource,
			$this->_r,
			$this->_g,
			$this->_b,
			((int)(127-$this->_a*127))
		);
	}
821321
protected function initDestImageResource() 
    {
    	// gif does not supports truecolor for resize
    	if (function_exists("ImageCreateTrueColor") && $this->getExtension() != 'gif') {
    		$this->destImageResource = ImageCreateTrueColor($this->destImageWidth, $this->destImageHeight);
    	} else {
    		$this->destImageResource = ImageCreate($this->destImageWidth, $this->destImageHeight);
    	}
    	
    	return $this;
    }
270842
public function applyFilter(Image $image)
    {
        $image->fit($this->params["w"], $this->params["h"]);

        return $image;
    }
423362
protected function &getResampleImageResource()
    {
        if ( ! is_resource($this->resampleImageResource)) {
            $this->resampleImageResource = $this->sourceImageResource;
        }

        return $this->resampleImageResource;
    }
1030537
public static function fromResource($resource) {
        $newImage = new self();
        try {
            $newImage->setResource($resource);
        } catch(\Exception $e) {
            throw new ImageException($e->getMessage(), ImageException::UnsupportedFormatException, $e);
        }
        return $newImage;
    }