@param Image $image

@return Image
160932
public function apply( $image ) {

        $pixels = array();
        $finalPx = array();
        // Localize vars
        $width = $image->getWidth();
        $height = $image->getHeight();

        // Loop
        $pixelIterator = $image->getCore()->getPixelIterator();
        foreach ($pixelIterator as $y => $rows) { /* Loop through pixel rows */
            foreach ( $rows as $x => $px ) { /* Loop through the pixels in the row (columns) */

                // row 0
                if ($x > 0 and $y > 0) {
                    $matrix[0][0] = $this->getColor($px, $pixels, $x - 1, $y - 1);
                } else {
                    $matrix[0][0] = $this->getColor($px, $pixels, $x, $y);
                }

                if ($y > 0) {
                    $matrix[1][0] = $this->getColor($px, $pixels, $x, $y - 1);
                } else {
                    $matrix[1][0] = $this->getColor($px, $pixels, $x, $y);
                }

                if ($x + 1 < $width and $y > 0) {
                    $matrix[2][0] = $this->getColor($px, $pixels, $x + 1, $y - 1);
                } else {
                    $matrix[2][0] = $this->getColor($px, $pixels, $x, $y);
                }

                // row 1
                if ($x > 0) {
                    $matrix[0][1] = $this->getColor($px, $pixels, $x - 1, $y);
                } else {
                    $matrix[0][1] = $this->getColor($px, $pixels, $x, $y);
                }

                if ($x + 1 < $width) {
                    $matrix[2][1] = $this->getColor($px, $pixels, $x + 1, $y);
                } else {
                    $matrix[2][1] = $this->getColor($px, $pixels, $x, $y);
                }

                // row 1
                if ($x > 0 and $y + 1 < $height) {
                    $matrix[0][2] = $this->getColor($px, $pixels, $x - 1, $y + 1);
                } else {
                    $matrix[0][2] = $this->getColor($px, $pixels, $x, $y);
                }

                if ($y + 1 < $height) {
                    $matrix[1][2] = $this->getColor($px, $pixels, $x, $y + 1);
                } else {
                    $matrix[1][2] = $this->getColor($px, $pixels, $x, $y);
                }

                if ($x + 1 < $width and $y + 1 < $height) {
                    $matrix[2][2] = $this->getColor($px, $pixels, $x + 1, $y + 1);
                } else {
                    $matrix[2][2] = $this->getColor($px, $pixels, $x, $y);
                }

                $edge = $this->convolve($matrix);
                $edge = intval($edge / 2);
                if ($edge > 255) {
                    $edge = 255;
                }

                /**
                 * @var \ImagickPixel $px Current pixel.
                 */
                $finalPx[] = $edge; // R
                $finalPx[] = $edge; // G
                $finalPx[] = $edge; // B

            }
            $pixelIterator->syncIterator(); /* Sync the iterator, this is important to do on each iteration */
        }

        $new = new \Imagick();
        $new->newImage($width, $height, new \ImagickPixel('black'));
        /* Import the pixels into image.
        width * height * strlen("RGB") must match count($pixels) */
        $new->importImagePixels(0, 0, $width, $height, "RGB", \Imagick::PIXEL_CHAR, $finalPx);

        $type = $image->getType();
        $file = $image->getImageFile();

        return new Image( $new, $file, $width, $height, $type ); // Create new image with updated core

    }
468765
public function apply( $image ) {

        $image->getCore()->sigmoidalContrastImage($this->amount > 0, $this->amount / 4, 0);
        return $image;
    }
1021674
public function getImage(Image $image)
    {
        if (is_null($this->watermarks)) {
            return;
        }

        if (!is_string($this->mark)) {
            return;
        }

        if ($this->mark === '') {
            return;
        }

        $path = $this->mark;

        if ($this->watermarksPathPrefix) {
            $path = $this->watermarksPathPrefix.'/'.$path;
        }

        if ($this->watermarks->has($path)) {
            $source = $this->watermarks->read($path);

            if ($source === false) {
                throw new FilesystemException(
                    'Could not read the image `'.$path.'`.'
                );
            }

            return $image->getDriver()->init($source);
        }
    }
477185
public function run(Image $image)
    {
        $coordinates = $this->getCoordinates($image);

        if ($coordinates) {
            $coordinates = $this->limitToImageBoundaries($image, $coordinates);

            $image->crop(
                $coordinates[0],
                $coordinates[1],
                $coordinates[2],
                $coordinates[3]
            );
        }

        return $image;
    }
270842
public function applyFilter(Image $image)
    {
        $image->fit($this->params["w"], $this->params["h"]);

        return $image;
    }
784462
public function execute($image)
    {
        $color = $this->argument(0)->required()->value();
        $color = new Color($color);
        $x = $this->argument(1)->type('digit')->required()->value();
        $y = $this->argument(2)->type('digit')->required()->value();

        // prepare pixel
        $draw = new \ImagickDraw;
        $draw->setFillColor($color->getPixel());
        $draw->point($x, $y);

        // apply pixel
        return $image->getCore()->drawImage($draw);
    }
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;
    }
333270
public function run(Image $image)
    {
        $brightness = $this->getBrightness();

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

        return $image;
    }
1267896
public function run(Image $image)
    {
        if ($flip = $this->getFlip()) {
            if ($flip === 'both') {
                return $image->flip('h')->flip('v');
            }

            return $image->flip($flip);
        }

        return $image;
    }
861660
public function run(Image $image)
    {
        $orientation = $this->getOrientation();

        if ($orientation === 'auto') {
            return $image->orientate();
        }

        return $image->rotate($orientation);
    }
482694
public function apply( $image ) {

        // normalize colorize levels
        $red = $this->normalizeLevel($this->red);
        $green = $this->normalizeLevel($this->green);
        $blue = $this->normalizeLevel($this->blue);
        $qrange = $image->getCore()->getQuantumRange();

        $image->getCore()->levelImage(0, $red, $qrange['quantumRangeLong'], \Imagick::CHANNEL_RED);
        $image->getCore()->levelImage(0, $green, $qrange['quantumRangeLong'], \Imagick::CHANNEL_GREEN);
        $image->getCore()->levelImage(0, $blue, $qrange['quantumRangeLong'], \Imagick::CHANNEL_BLUE);

        return $image;
    }
679381
public function execute($image)
    {
        $source = $this->argument(0)->required()->value();
        $position = $this->argument(1)->type('string')->value();
        $x = $this->argument(2)->type('digit')->value(0);
        $y = $this->argument(3)->type('digit')->value(0);

        // build watermark
        $watermark = $image->getDriver()->init($source);

        // define insertion point
        $image_size = $image->getSize()->align($position, $x, $y);
        $watermark_size = $watermark->getSize()->align($position);
        $target = $image_size->relativePosition($watermark_size);

        // insert image at position
        return $image->getCore()->compositeImage($watermark->getCore(), \Imagick::COMPOSITE_DEFAULT, $target->x, $target->y);
    }
154052
public function storePermanentImage (Image $image)
    {
        $json = $this->storeGenericMedia(MediaType::IMAGE, true, $image);

        return (new Uploaded\Image($json->media_id))->withURL($json->url);
    }
16847
public function execute($image)
    {
        $mode = $this->argument(0)->value('h');

        $size = $image->getSize();
        $dst = clone $size;

        switch (strtolower($mode)) {
            case 2:
            case 'v':
            case 'vert':
            case 'vertical':
                $size->pivot->y = $size->height - 1;
                $size->height = $size->height * (-1);
                break;

            default:
                $size->pivot->x = $size->width - 1;
                $size->width = $size->width * (-1);
                break;
        }

        return $this->modify($image, 0, 0, $size->pivot->x, $size->pivot->y, $dst->width, $dst->height, $size->width, $size->height);
    }
1189546
public function execute($image)
    {
        $mask_source = $this->argument(0)->value();
        $mask_w_alpha = $this->argument(1)->type('bool')->value(false);

        // get imagick
        $imagick = $image->getCore();

        // build mask image from source
        $mask = $image->getDriver()->init($mask_source);

        // resize mask to size of current image (if necessary)
        $image_size = $image->getSize();
        if ($mask->getSize() != $image_size) {
            $mask->resize($image_size->width, $image_size->height);
        }

        $imagick->setImageMatte(true);

        if ($mask_w_alpha) {

            // just mask with alpha map
            $imagick->compositeImage($mask->getCore(), \Imagick::COMPOSITE_DSTIN, 0, 0);

        } else {

            // get alpha channel of original as greyscale image
            $original_alpha = clone $imagick;
            $original_alpha->separateImageChannel(\Imagick::CHANNEL_ALPHA);

            // use red channel from mask ask alpha
            $mask_alpha = clone $mask->getCore();
            $mask_alpha->compositeImage($mask->getCore(), \Imagick::COMPOSITE_DEFAULT, 0, 0);
            // $mask_alpha->setImageAlphaChannel(\Imagick::ALPHACHANNEL_DEACTIVATE);
            $mask_alpha->separateImageChannel(\Imagick::CHANNEL_ALL);

            // combine both alphas from original and mask
            $original_alpha->compositeImage($mask_alpha, \Imagick::COMPOSITE_COPYOPACITY, 0, 0);

            // mask the image with the alpha combination
            $imagick->compositeImage($original_alpha, \Imagick::COMPOSITE_DSTIN, 0, 0);
        }

        return true;
    }
704102
public function applyFilter(\Intervention\Image\Image $image)
    {
        $image->pixelate($this->size);
        $image->greyscale();

        return $image;
    }
159208
public function run(Image $image)
    {
        $blur = $this->getBlur();

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

        return $image;
    }