@param ImagineImageInterface $image

@return ImagineImageInterface
506187
public function updateFile(ImagineImageInterface $image)
    {
        $this->originWidth = $image->getSize()->getWidth();
        $this->originHeight = $image->getSize()->getHeight();

        // Resize 
        $this->resize();

        $resize = new ImagineResize(
            new Box($this->resizeWidth, $this->resizeHeight)
        );
        $image = $resize->apply($image);

        // Crop
        $this->crop();
        $crop = new ImagineCrop(
            new Point($this->targetLeft, $this->targetTop),
            new Box($this->targetWidth, $this->targetHeight)
        );

        $image = $crop->apply($image);

        return $image;
    }
489578
protected static function ensureImageInterfaceInstance($image)
    {
        if ($image instanceof ImageInterface) {
            return $image;
        }

        if (is_resource($image)) {
            return static::getImagine()->read($image);
        }

        if (is_string($image)) {
            return static::getImagine()->open(Yii::getAlias($image));
        }

        throw new InvalidParamException('File should be either ImageInterface, resource or a string containing file path.');
    }
1364210
public function setImage(\Imagick $image)
    {
        $this->originalImage = $image;

        // set base image dimensions
        $this->setBaseDimensions(
            $this->originalImage->getImageWidth(),
            $this->originalImage->getImageHeight()
        );
        return $this;
    }
206549
public function flatten(&$image){
        if($image->isAnimated()){
            $imagick = $image->getCore()->mergeImageLayers(\Imagick::LAYERMETHOD_FLATTEN);
            $image = new Image(
                $imagick,
                $image->getImageFile(),
                $image->getWidth(),
                $image->getHeight(),
                $image->getType(),
                '', // blocks
                false // animated
            );
        }
        return $this;
    }
339655
public function image($image = null)
    {
        if (null === $image) {
            return $this->image;
        }

        $this->image = $image;

        return $this;
    }
1172576
public function run(Image $image)
    {
        if (is_null($this->bg)) {
            return $image;
        }

        $color = (new Color($this->bg))->formatted();

        if ($color) {
            $new = $image->getDriver()->newImage($image->width(), $image->height(), $color);
            $new->mime = $image->mime;
            $image = $new->insert($image, 'top-left', 0, 0);
        }

        return $image;
    }
333270
public function run(Image $image)
    {
        $brightness = $this->getBrightness();

        if ($brightness !== null) {
            $image->brightness($brightness);
        }

        return $image;
    }
296055
public function apply(ImageInterface $image)
    {
        if (!$image instanceof Image) {
            throw new InvalidArgumentException("This filter is supported by Image Magick driver only!");
        }
        return $image->applyMask($this->shapeMask)->removeTransparency(new Color('fff'));
    }
1360309
protected function handleImageManipulation(ImageInterface $image, array $data): ImageInterface
    {
        $width = $height = $data['dimension'];

        return $image->thumbnail(new Box($width, $height), $data['mode'], $data['filter']);
    }
1246911
protected function createImageCanvas($image)
    {
        $this->type = $this->mime->type($image, 1);
            
        $this->imageSize = ! isset($this->width) ? getimagesize($image) : [$this->width ?? 0, $this->height ?? 0];

        $this->canvas = $this->createFrom($image,
        [
            # For type gd2p
            'x'      => $this->x      ?? 0,
            'y'      => $this->y      ?? 0,
            'width'  => $this->width  ?? $this->imageSize[0],
            'height' => $this->height ?? $this->imageSize[1]
        ]);
    }
1145976
public function apply(ImageInterface $image)
    {
        /** @var \Imagick $imagick */
        $imagick = $image->getImagick();
        $imagick->reduceNoiseImage((float)$this->getOption('radius', 0));

        return $image;
    }
519371
final public function make(ImageInterface $image)
    {
        $this->response = new Response(null, 200);
        $this->response->setPublic();

        $lastMod = (new \DateTime)->setTimestamp($modDate = $image->getLastModTime());
        $mod = strtotime($this->request->headers->get('if-modified-since', time()));

        if (($image instanceof CachedImage || !$image->isProcessed()) && $mod === $modDate) {
            $this->setHeadersIfNotProcessed($this->response, $lastMod);
        } else {
            $this->setHeaders($this->response, $image, $lastMod);
        }
    }
270842
public function applyFilter(Image $image)
    {
        $image->fit($this->params["w"], $this->params["h"]);

        return $image;
    }
1235083
function load(ImageInterface $image, array $options = [])
    {
        if (!array_key_exists('file', $options)) {
            throw new InvalidArgumentException('Expected mask file path, none given');
        }

        if (!file_exists($options['file'])) {
            throw new InvalidArgumentException("Mask file doesn't exists");
        }

        $mask = new ApplyShape($this->imagine->open($options['file']));

        return $mask->apply($image);
    }
627483
public function createFrom($image)
    {
        $type           = pathinfo($image, PATHINFO_EXTENSION);
        $type           = ($type === 'jpg') ? 'jpeg' : $type;
        $createFrom     = 'ImageCreateFrom' . $type;

        return $createFrom($image);
    }
162239
public function execute($image)
    {
        $level = $this->argument(0)->between(-100, 100)->required()->value();

        return $image->getCore()->sigmoidalContrastImage($level > 0, $level / 4, 0);
    }
509314
public function apply( $image ) {

        imagefilter($image->getCore(), IMG_FILTER_PIXELATE, $this->amount, true);
        return $image;
    }