Gets an `Image` instance
@return \Intervention\Image\Image
@throws RuntimeException
@uses $ImageManager
@uses $path
480636
protected function getImageInstance()
    {
        //Tries to create the image instance
        try {
            $imageInstance = $this->ImageManager->make($this->path);
        } catch (NotReadableException $e) {
            $message = __d('thumber', 'Unable to read image from file `{0}`', rtr($this->path));

            if ($e->getMessage() == 'Unsupported image type. GD driver is only able to decode JPG, PNG, GIF or WebP files.') {
                $message = __d('thumber', 'Image type `{0}` is not supported by this driver', mime_content_type($this->path));
            }

            throw new RuntimeException($message);
        }

        return $imageInstance;
    }
825686
public function defaultImage()
    {
        // Return an empty Image object if no default value
        if (empty($this->value)) {
            return new Image;
        }

        // All src images must live in the /img (relative) directory
        if (!Str::is('/img/*', $this->value)) {
            $msg = 'Element images must be stored in public/img: '.$this->value;
            throw new Exception($msg);
        }

        // Check if the image already exists in the uploads directory
        $src = $this->value;
        $src_abs = public_path($src);
        $path = str_replace('/img/', '/elements/', $src);
        if (!app('upchuck.disk')->has($path)) {

            // Copy it to the disk
            $stream = fopen($src_abs, 'r+');
            app('upchuck.disk')->writeStream($path, $stream);
            fclose($stream);
        }

        // Wrap the touching of the element and images table in a transaction
        // so that the element isn't updated if the images write fails
        DB::beginTransaction();

        // Update or create this Element instance
        $this->value = app('upchuck')->url($path);
        $this->save();

        // Create and return new Image instance. The Image::populateFileMeta()
        // requires an UploadedFile, so we need to do it manually here.
        $size = getimagesize($src_abs);
        $image = new Image([
            'file' => $this->value,
            'name' => $this->inputName(),
            'file_type' => pathinfo($src_abs, PATHINFO_EXTENSION),
            'file_size' => filesize($src_abs),
            'width'     => $size[0],
            'height'    => $size[1],
        ]);
        $this->images()->save($image);
        DB::commit();

        // Clear cached image relations
        unset($this->relations['images']);

        // Return the image
        return $image;
    }
357054
public function getFile()
    {
        if ($this->fileDetected) {
            return $this->file;
        }

        $this->handle = null;
        $file = &$this->file;

        if (!is_dir($this->dir) && !@mkdir($this->dir, 0755, true)) {
            $message = sprintf('Fail to create directory "%s"', $this->dir);
            ($e = error_get_last()) && $message .= ': ' . $e['message'];
            throw new \RuntimeException($message);
        }

        $file = realpath($this->dir) . '/' . date($this->fileFormat);

        if ($this->fileSize) {
            $firstFile = $file;

            $files = glob($file . '*', GLOB_NOSORT);

            if (1 < count($files)) {
                natsort($files);
                $file = array_pop($files);
            }

            if (is_file($file) && $this->fileSize < filesize($file)) {
                $ext = pathinfo($file, PATHINFO_EXTENSION);
                if (is_numeric($ext)) {
                    $file = $firstFile . '.' . ($ext + 1);
                } else {
                    $file = $firstFile . '.1';
                }
            }
        }

        $this->fileDetected = true;

        return $file;
    }
784088
public function image()
    {
        if (!\count($this)) {
            throw new \InvalidArgumentException('The current node list is empty.');
        }

        $node = $this->getNode(0);

        if (!$node instanceof \DOMElement) {
            throw new \InvalidArgumentException(sprintf('The selected node should be instance of DOMElement, got "%s".', \get_class($node)));
        }

        return new Image($node, $this->baseHref);
    }
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!');
	}
831855
public function Image()
    {
        if ($this->ActionImage()) {
            return $this->ActionImage();
        }
        if ($this->Type == 'SiteTree') {
            return $this->SiteTree()->ActionImage();
        }
    }
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;
    }
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;

    }
830339
protected function initSourceImageResource() 
    { 
    	$ext = $this->getExtension();
    	
    	switch($ext) {
		case 'gif':
			$this->sourceImageResource = ImageCreateFromGif($this->sourceImagePath);
			break;
    	
		case 'jpg':
			$this->sourceImageResource = ImageCreateFromJpeg($this->sourceImagePath);
			break;
    	
		case 'png':
			$this->sourceImageResource = ImageCreateFromPng($this->sourceImagePath);
			break;
    	
		default:
			throw new \RuntimeException("An error occurred trying to create the image, extension '" . $ext. "' is not supported");
			break;
    	}
    	
    	return $this;
    }
347724
public function toPNG()
    {
        $this->extension = 'png';
        $this->type = IMAGETYPE_PNG;
        $this->mimetype = Utils::getMimetypeByImageType(IMAGETYPE_PNG);
        return $this;
    }
201562
public function PrimaryImage()
    {
        // If we have associated an image, return it
        $image = $this->owner->Image();

        if ($image->exists()) {
            return $image;
        }

        // Next try and get a child product image
        $product = $this->owner->AllProducts()->first();

        if (!empty($product)) {
            return $product->PrimaryImage();
        }

        // Finally generate our no product image
        return Helper::generate_no_image();
    }
1149651
public function getAsImage()
    {
        if ($this->asImage === null) {
            $this->asImage = $this->getGenerator()->generateImage($this);;
        }
        return $this->asImage;
    }
1203414
public function loadToString($image)
    {
        $srcStorage = $this->getImageStorage($image);
        if ($srcStorage !== DriverInterface::IMAGE_STORAGE_STRING) {
            $image = @file_get_contents($image);
            if (false === $image) {
                throw new Exception\RuntimeException('could not load image');
            }
        }
        return $image;
    }
1050370
public function getMetaImageFolder()
    {
        if ($folder = $this->owner->config()->meta_image_folder) {
            return $folder;
        }
        
        return Config::inst()->get(self::class, 'default_meta_image_folder');
    }
594360
public function getFile()
    {
        if ($this->file && get_class($this->file) != $this->file->ClassName) {
            // If the class is Image and the ClassName says it should be a CloudImage, just reload it
            $this->file = DataObject::get($this->file->ClassName)->byID($this->file->ID);
        }

        return $this->file;
    }
1268166
public function image()
    {
        if ($this->relationLoaded('mediables')) {
            return $this->mediables->where('type', 'image')->first();
        }

        return $this->mediables()
            ->where('media.type', 'image')
            ->whereNull('mediables.type')
            ->first();
    }
361696
public function Image()
    {
        $product = $this->FindStockItem();

        if ($product && method_exists($product, "SortedImages")) {
            return  $product->SortedImages()->first();
        } elseif ($product && method_exists($product, "Images")) {
            return $product->Images()->first();
        } elseif ($product && method_exists($product, "Image") && $product->Image()->exists()) {
            return $product->Image();
        }
    }