@param Image $image

@return Item
556542
public function addImage(Image $image)
    {
        $images = array_map('strval', $this->images->toArray());
        if (!in_array($image->getSource(), $images)) {
            $this->images->add($image);
            $image->setItem($this);
        }

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

        return $createFrom($image);
    }
354362
public function applyFilter(Image $image)
    {
        if ($image->width() >= $image->height())
        {
            return $image->resize(272, null, function ($constraint)
            {
                $constraint->aspectRatio();
            });
        }

        return $image->resize(null, 272, function ($constraint)
        {
            $constraint->aspectRatio();
        });
    }
886644
public function execute($image)
    {
        $red = $this->argument(0)->between(-100, 100)->required()->value();
        $green = $this->argument(1)->between(-100, 100)->required()->value();
        $blue = $this->argument(2)->between(-100, 100)->required()->value();

        // normalize colorize levels
        $red = round($red * 2.55);
        $green = round($green * 2.55);
        $blue = round($blue * 2.55);

        // apply filter
        return imagefilter($image->getCore(), IMG_FILTER_COLORIZE, $red, $green, $blue);
    }
838194
public function loadFromString($image)
    {
        $resource = @imagecreatefromstring($image);

        if (!is_resource($resource)) {
            throw new Exception\RuntimeException('image could not be loaded');
        }

        return $resource;
    }
983781
public function execute($image)
    {
        $amount = $this->argument(0)->between(0, 100)->value(10);

        // build matrix
        $min = $amount >= 10 ? $amount * -0.01 : 0;
        $max = $amount * -0.025;
        $abs = ((4 * $min + 4 * $max) * -1) + 1;
        $div = 1;

        $matrix = [
            [$min, $max, $min],
            [$max, $abs, $max],
            [$min, $max, $min]
        ];

        // apply the matrix
        return imageconvolution($image->getCore(), $matrix, $div, 0);
    }
1137754
public function getRequest(Image $image, $responseType = self::RESPONSE_TYPE_OBJECT)
    {
        return $this->request($image, $responseType);
    }
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.');
    }
1222741
public function setImage($image)
    {
        if (getimagesize($image)) {
            if (strpos($image, 'http') === false) {
                loader()->loadHelper('url');
                $image = images_url($image);
            }

            $this->setObject('image', $image);
        }

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

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

        return $image;
    }
1188996
public function setImage($image)
    {
        if ($image instanceof FeedImage) {
            $this->image = $image;
        } elseif (is_array($image)) {
            if (!empty($image)) {
                $this->image = FeedImage::createFromArray($image);
            }
        } elseif (is_null($image)) {
            $this->image = null;
        } else {
            throw new \InvalidArgumentException('Invalid image');
        }

        return $this;
    }
491472
public function open($image) {
		if (!file_exists($image)) {
			throw new \RuntimeException(sprintf('File `%s` does not exist!', $image));
		}
		$this->_image = $this->imagine()->open($image);
		return $this;
	}
628356
public function run(Image $image)
    {
        $sharpen = $this->getSharpen();

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

        return $image;
    }
468765
public function apply( $image ) {

        $image->getCore()->sigmoidalContrastImage($this->amount > 0, $this->amount / 4, 0);
        return $image;
    }
1143681
private function ordered( $image ) {
        // Localize vars
        $width  = $image->getWidth();
        $height = $image->getHeight();
        $old    = $image->getCore();

        $new = imagecreatetruecolor( $width, $height );

        $thresholdMap = array(
            array( 15, 135, 45, 165 ),
            array( 195, 75, 225, 105 ),
            array( 60, 180, 30, 150 ),
            array( 240, 120, 210, 90 )
        );

        for ( $y = 0; $y < $height; $y += 1 ) {
            for ( $x = 0; $x < $width; $x += 1 ) {

                $color = imagecolorat( $old, $x, $y );
                $r     = ( $color >> 16 ) & 0xFF;
                $g     = ( $color >> 8 ) & 0xFF;
                $b     = $color & 0xFF;

                $gray = round( $r * 0.3 + $g * 0.59 + $b * 0.11 );

                $threshold = $thresholdMap[ $x % 4 ][ $y % 4 ];
                $oldPixel  = ( $gray + $threshold ) / 2;
                if ( $oldPixel <= 127 ) { // Determine if black or white. Also has the benefit of clipping excess value
                    $newPixel = 0;
                } else {
                    $newPixel = 255;
                }

                // Current pixel
                imagesetpixel( $new, $x, $y,
                    imagecolorallocate( $new,
                        $newPixel,
                        $newPixel,
                        $newPixel
                    )
                );

            }
        }

        imagedestroy( $old ); // Free resource
        // Create new image with updated core
        return new Image(
            $new,
            $image->getImageFile(),
            $width,
            $height,
            $image->getType()
        );
    }
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);
    }
596863
public function run(Image $image)
    {
        if ($border = $this->getBorder($image)) {
            list($width, $color, $method) = $border;

            if ($method === 'overlay') {
                return $this->runOverlay($image, $width, $color);
            }

            if ($method === 'shrink') {
                return $this->runShrink($image, $width, $color);
            }

            if ($method === 'expand') {
                return $this->runExpand($image, $width, $color);
            }
        }

        return $image;
    }