Gets an image from a file string or returns the image object that is
loaded in the ImageProcessor::_image property.

@param string|null $Image
@return \Imagine\Image\
488969
protected function _getImage($Image = null) {
		if (is_string($Image)) {
			$class = 'Imagine\\' . $this->config('engine') . '\Imagine';
			$Imagine = new $class();
			return $Imagine->open($Image);
		}
		if (!empty($this->_image)) {
			return $this->_image;
		}
		throw new \RuntimeException('Could not get the image object!');
	}
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;
    }
1073204
public function run(Image $image)
    {
        $pixelate = $this->getPixelate();

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

        return $image;
    }
747797
public function from($element = null)
    {
        if (!empty($element) && $element instanceof Image) {
            foreach (get_object_vars($element) as $key => $value) {
                $this->$key = $value;
            }

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

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

        return $image;
    }
894046
public function getImageStorage($image)
    {
        if (@file_exists('file://' . $image)) {
            return DriverInterface::IMAGE_STORAGE_FILE;
        } elseif (false === strpos($image, '://')) {
            return DriverInterface::IMAGE_STORAGE_STRING;
        } else {
            return DriverInterface::IMAGE_STORAGE_URL;
        }
    }
308027
protected function makeGD($image)
  {
    if (is_resource($image)) {
      return $image;
    }

    if (!is_file($image)) {
      Ex::ThrowError(Ex::FILE_NOT_EXIST, $image);
    }

    $this->type = $this->getTypeByFile($image);

    switch ($this->type) {
      case IMG_JPEG:
        return imagecreatefromjpeg($image);
        break;
      case IMG_GIF:
        return imagecreatefromgif($image);
        break;
      case IMG_PNG:
        return imagecreatefrompng($image);
        break;
      default:
        $file = file_get_contents($image);

        return imagecreatefromstring($file);
    }
  }
298249
public function execute($image)
    {
        $size = $this->argument(0)->type('digit')->value(10);

        return imagefilter($image->getCore(), IMG_FILTER_PIXELATE, $size, true);
    }
679548
protected function getImage( $path = null )
    {
        if ( is_null( $this->image ) )
        {
            if ( is_null( $path ) )
            {
                $this->image = Image::create(
                    $this->width,
                    $this->height
                );
            }
            else
            {
                $this->image = Image::open( $path );
            }
        }

        return $this->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;
    }
1287455
public function setDefaultImage($image)
    {
        if ($image !== false) {
            $this->cachedParams = null;

            $image = in_array(strtolower($image), $this->supportedImages)
                ? strtolower($image)
                : $this->checkImageUrl($image);
        }

        $this->defaultImage = $image;

        return $this;
    }
522046
public function run(Image $image)
    {
        $gamma = $this->getGamma();

        if ($gamma) {
            $image->gamma($gamma);
        }

        return $image;
    }
351755
private function storeImage(Image $image)
    {
        $file = $this->getFile($image);

        if (!$file instanceof \SplFileInfo) {
            return null;
        }

        $path = $this->imageManagerInterface->store($file);

        return $image->setPath($path);
    }
714652
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
        imagealphablending($image->getCore(), true);
        return imagecopy($image->getCore(), $watermark->getCore(), $target->x, $target->y, 0, 0, $watermark_size->width, $watermark_size->height);
    }
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;
    }
157019
protected function getReplacementImage(Image $image)
    {
        // Check that the image is in the elements dir, which means it's
        // a default image
        if (!strpos($image->file, '/elements/')) {
            return;
        }

        // Get the current file value form the YAML.  Need to check for the
        // shorthand with the type suffix as well.
        $yaml = app('decoy.elements')->assocConfig();
        $replacement = $yaml[$this->key]['value'];

        // Check if the filenames are the same
        if (pathinfo($image->file, PATHINFO_BASENAME)
            == pathinfo($replacement, PATHINFO_BASENAME)) {
            return;
        }

        // Since the filenames are not the same, remove the old image and generate
        // a new one
        $image->delete();
        $this->exists = true; // It actually does exist if there was an Image
        $this->value = $replacement;

        return $this->defaultImage();
    }
1271821
public static function get($file)
    {
        $type = str_replace('image/', NULL, Singleton::class('ZN\Helpers\Mime')->type($file));

        return $type === 'jpg' ? 'jpeg' : $type;
    }