@param string $path

@return Image
344871
private function createFromGif(string $path): self
    {
        $imageData = imagecreatefromgif($path);
        if (false === $imageData) {
            throw new ImageException(sprintf('Unable to create GIF image from %s!', $path));
        }
        $this->workingData = $imageData;
        $this->setTransparency();
        $this->encrypted = false;
        return $this;
    }
636745
protected function get_thumbnail_path($path) {
        $relative_path = $this->getRelativePath($path);
        $thumbnail_path = $this->path_to_files . '/' . $this->config['images']['thumbnail']['dir'] . '/';

        if (is_dir($path)) {
            $thumbnail_fullpath = $thumbnail_path . $relative_path . '/';
        } else {
            $thumbnail_fullpath = $thumbnail_path . dirname($relative_path) . '/' . basename($path);
        }

        return $this->cleanPath($thumbnail_fullpath);
    }
205786
public function loadImage(string $path): self
    {
        $this->image = new Image($this->secret, $path, null, $this->autorotate);
        return $this;
    }
48815
public function asset($path)
    {
        if (null !== $this->basePath) {
            return $this->request->getUri()->getBaseUrl().'/'.trim($this->basePath, '/').'/'.$path;
        }

        return $this->request->getUri()->getBaseUrl().'/'.$path;
    }
819071
protected function getFilePath(string $path): string
    {
        if (empty($path)) {
            $path = $this->fileName;
        }

        return $path;
    }
14754
protected function fromFileType($path)
    {
        switch( Filesystem::getExtension($path) )
        {
            case 'png' : return imagecreatefrompng($path);
            case 'gif' : return imagecreatefromgif($path);
            case 'jpg' :
            case 'jpeg':
            default    : return imagecreatefromjpeg($path);
        }
    }
1199047
public function loadFile($path)
	{
		// Destroy the current image handle if it exists
		$this->destroy();

		// Make sure the file exists.
		if (!file_exists($path))
		{
			throw new \InvalidArgumentException('The image file does not exist.');
		}

		// Get the image properties.
		$properties = static::getImageFileProperties($path);

		// Attempt to load the image based on the MIME-Type
		switch ($properties->mime)
		{
			case 'image/gif':
				// Make sure the image type is supported.
				if (empty(static::$formats[IMAGETYPE_GIF]))
				{
					// @codeCoverageIgnoreStart
					$this->getLogger()->error('Attempting to load an image of unsupported type GIF.');

					throw new \RuntimeException('Attempting to load an image of unsupported type GIF.');

					// @codeCoverageIgnoreEnd
				}

				// Attempt to create the image handle.
				$handle = imagecreatefromgif($path);

				if (!\is_resource($handle))
				{
					// @codeCoverageIgnoreStart
					throw new \RuntimeException('Unable to process GIF image.');

					// @codeCoverageIgnoreEnd
				}

				$this->handle = $handle;

				break;

			case 'image/jpeg':
				// Make sure the image type is supported.
				if (empty(static::$formats[IMAGETYPE_JPEG]))
				{
					// @codeCoverageIgnoreStart
					$this->getLogger()->error('Attempting to load an image of unsupported type JPG.');

					throw new \RuntimeException('Attempting to load an image of unsupported type JPG.');

					// @codeCoverageIgnoreEnd
				}

				// Attempt to create the image handle.
				$handle = imagecreatefromjpeg($path);

				if (!\is_resource($handle))
				{
					// @codeCoverageIgnoreStart
					throw new \RuntimeException('Unable to process JPG image.');

					// @codeCoverageIgnoreEnd
				}

				$this->handle = $handle;

				break;

			case 'image/png':
				// Make sure the image type is supported.
				if (empty(static::$formats[IMAGETYPE_PNG]))
				{
					// @codeCoverageIgnoreStart
					$this->getLogger()->error('Attempting to load an image of unsupported type PNG.');

					throw new \RuntimeException('Attempting to load an image of unsupported type PNG.');

					// @codeCoverageIgnoreEnd
				}

				// Attempt to create the image handle.
				$handle = imagecreatefrompng($path);

				if (!\is_resource($handle))
				{
					// @codeCoverageIgnoreStart
					throw new \RuntimeException('Unable to process PNG image.');

					// @codeCoverageIgnoreEnd
				}

				$this->handle = $handle;

				break;

			default:
				$this->getLogger()->error('Attempting to load an image of unsupported type ' . $properties->mime);

				throw new \InvalidArgumentException('Attempting to load an image of unsupported type ' . $properties->mime);
		}

		// Set the filesystem path to the source image.
		$this->path = $path;
	}
1129490
static public function img($path, $with_version = true) {
        $url = $path;
        if($with_version) {
            $ver = self::cssVer();
            $url .= (strpos($url, '?') === false ? '?' : '&') . "version={$ver}";
        }
        return $url;
    }
1350910
public function save($path)
    {

        switch ( $this->imageType ) {
            case IMAGETYPE_GIF:
                $returnData = imagegif( $this->image, $path );
                break;

            case IMAGETYPE_PNG:
                $returnData = imagepng( $this->image, $path );
                break;

            case IMAGETYPE_JPEG:
                $returnData = imagejpeg( $this->image, $path );
                break;

            case IMAGETYPE_BMP:
                $returnData = imagewbmp( $this->image, $path );
                break;

            // If the image is not one of the previous mimetype
            // We throw an exception
            default:
                throw new Exception( sprintf( 'This MimeType is not supported: %s. Image processed: %s', image_type_to_mime_type( $this->imageType ), $this->originalImagePath ) );
                break;
        }

        // Return this for chaning
        return $this;
    }
402932
public static function get($path)
    {
        if (is_dir($path)) {
            return new filesystem\Directory($path);
        }
        return new filesystem\File($path);
    }
549688
public function watermark($path = null)
    {
        if (is_null($path)) {
            $this->watermarkPath(config('images.watermark_path'));
        }
        $this->watermarkPath($path);
        $this->todo('watermark');

        return $this;
    }
971238
public function path($path)
    {
        $path  = strtolower(trim($path));
        $first = substr($path, 0, 1);
        
        if ($first == '@' && isset($this->aliases[$path])) {
            $path = $this->aliases[$path];
            
        } elseif ($first == '/') {
            $path = preg_replace('/\\//', $this->root() . '/', $path, 1);
            
        }
        if ($path = realpath($path)) {
            $path = static::clean($path);
        }
        
        return $path;
    }
1277754
private function fixPath($path)
    {
        $helper = $this->getAssets();

        if ($helper === null) {
            return $path;
        }

        $url = $helper->getUrl($path);

        if (substr($path, -1) === '/' && ($position = strpos($url, '?')) !== false) {
            $url = substr($url, 0, $position);
        }

        return $url;
    }
791284
private function createFromPng(string $path): self
    {
        $imageData = imagecreatefrompng($path);
        if (false === $imageData) {
            throw new ImageException(sprintf('Unable to create PNG image from %s!', $path));
        }
        $this->workingData = $imageData;
        $this->setTransparency(false, true);
        $this->encrypted = false;
        return $this;
    }
1154768
public function cleanThumbnails($path = '')
    {
        $cleanPathInfo = new SplFileInfo(realpath($this->getDocumentRoot() . DIRECTORY_SEPARATOR . $path));

        if (strpos($cleanPathInfo->getRealPath(), $this->getDocumentRoot()) === 0) {
            if ($cleanPathInfo->isDir()) {
                // Clean thumbnails in specified directory
                $dirIterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($cleanPathInfo->getRealPath()), RecursiveIteratorIterator::SELF_FIRST);

                foreach ($dirIterator as $path => $splFileObject) {
                    /* @var SplFileObject $splFileObject */
                    if (!in_array($splFileObject->getBasename(), ['.', '..'])
                        && preg_match('#.*-' . $this->getThumbnailPrefix() . '-([\w\d]+)\.(' . implode('|', $this->getAllowedExtensions()) . ')$#', $splFileObject->getBasename())
                    ) {
                        unlink($splFileObject->getRealPath());
                    }
                }

                return true;

            } elseif ($cleanPathInfo->isFile() && in_array($cleanPathInfo->getExtension(), $this->getAllowedExtensions())) {
                // Clean thumbnails for one image
                $imagePathRemExt = $cleanPathInfo->getPath() . DIRECTORY_SEPARATOR . $cleanPathInfo->getBasename('.' . $cleanPathInfo->getExtension());

                $thumbnails = glob($imagePathRemExt . '-' . $this->getThumbnailPrefix() . '-*');
                foreach ($thumbnails as $thumbnailPath) {
                    unlink($thumbnailPath);
                }

                return true;
            }
        }

        return false;
    }
1001693
public function getSourcePath($path)
    {
        $path = trim($path, '/');
        
        $baseUrl = $this->baseUrl.'/';

        if (substr($path, 0, strlen($baseUrl)) === $baseUrl) {
            $path = trim(substr($path, strlen($baseUrl)), '/');
        }

        if ($path === '') {
            throw new FileNotFoundException('Image path missing.');
        }

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

        return rawurldecode($path);
    }
561761
public static function getFile(string $path): string {
		$e = explode("/", rtrim($path, "/"));

		return $e[count($e) - 1];
	}