Ecrit la portion d'image dans un fichier

@param string $path  Chemin du fichier
@throws \Exception
179669
public function write($path)
  {
    if ($this->srcImage->getExtension() == Image::IMAGE_TYPE_JPG) {
      imagejpeg($this->cuttedRessource, $path, $this->srcImage->getJpgQuality());
    } else if ($this->srcImage->getExtension() == Image::IMAGE_TYPE_PNG) {
      imagepng($this->cuttedRessource, $path, $this->srcImage->getPngCompression());
    } else {
      throw new \Exception('Impossible de générer l\'image : extension non supportée');
    }
  }
1237446
public static function parse($path) {
        if (!file_exists($path)) {
            throw new \Exception("$path not found");
        }

        $src = file_get_contents($path);
        if (!$src) {
            throw new \Exception("could not read $path");
        }

        // first of all do we have any frontmatter in there?
        preg_match(self::$frontmatter_regex, $src, $matches);
        if (!empty($matches)) {
            // if we have an empty frontmatter, this will fail 
            // but we still want to act like there was something there
            if (!($frontmatter = json_decode(trim($matches[1]), true))) {
                $frontmatter = array();
            }
        } else {
            $frontmatter = false;
        }

        // remove any frontmatter
        $plain_src = preg_replace(self::$frontmatter_regex, "", $src);

        return array(
            'frontmatter' => $frontmatter,
            'content' => $plain_src
        );
    }
112015
private function setSchemaFromPath($path)
    {
        if (!file_exists($path)) {
            throw new Exception("Arquivo json não encontrado em diretório [{ $path }] fornecido", 400);
        }

        if (!isset(self::$schema)) {
            self::$schema = Schema::make(file_get_contents($path));
        }
    }
701391
public function verify($path) {
		$full_path = realpath($path);
		$data = @getimagesize($full_path);
		if (!$data) {
			throw new FileException(sprintf('File "%s" cannot be read.', $path), 1);
		}
		if ($data[2] != IMG_JPG) {
			throw new FileException(sprintf('File "%s" is not a JPG.', $path), 240);
		}
		if ($data[0] < 600 || $data[1] < 600) {
			throw new FileException(sprintf('File "%s" is too small.', $path), 241);
		}
		return $full_path;
	}
298983
public function normalizePath($path)
	{
		$path = rtrim($path, '/\\').DIRECTORY_SEPARATOR;
		$path = realpath($path).DIRECTORY_SEPARATOR;

		if ($this->root and strpos($path, $this->root) !== 0)
		{
			throw new \Exception('Cannot access path outside: '.$this->root.'. Trying to access: '.$path);
		}

		return $path;
	}
1237955
public function setStoragePath($path) {
		$dir  = pathinfo($path, PATHINFO_DIRNAME);
		$name = pathinfo($path, PATHINFO_BASENAME);
		
		$dir = realpath($dir);
		
		if ($dir === false) {
			throw new Exceptions\MetadataError('Invalid path: "' . $path . '"');
		}
		
		$this->metadataPath = $dir . DIRECTORY_SEPARATOR . $name;
	}
243478
public static function readdir($path)
		{
			// initialisation variable de retour
			$ret = array();

			// on gère par sécurité la fin du path pour ajouter ou pas le /
			if ('/' != substr($path, -1)) {
				$path .= '/';
			}

			// on vérifie que $path est bien un répertoire
			if (is_dir($path)) {
				// ouverture du répertoire
				if ($dir = opendir($path)) {
					// on parcours le répertoire
					while (false !== ($dirElt = readdir($dir))) {
						if ($dirElt != '.' && $dirElt != '..') {
							if (!is_dir($path . $dirElt)) {
								$ret[] = $path . $dirElt;
							} else {
								$ret[] = static::readdir($path . $dirElt);
							}
						}
					}

					// fermeture du répertoire
					closedir($dir);
				} else {
					throw new Exception('error while opening ' . $path);
				}
			} else {
				throw new Exception($path . ' is not a directory');
			}

			return Arrays::flatten($ret);
		}
131362
public function setPath($path)
        {
            if ($this->validatePath($path) === false) {
                throw new Exception("Path \"$path\" is not a valid HTTP path");
            }

            $oldPath     = $this->_path;
            $this->_path = $path;

            return $oldPath;
        }
723235
public function save($path, $fullPath = false)
    {
        if ( !$fullPath ) {

            // var_dump( [ $this->getWidth(), $this->getHeight() ] );
            $path = sprintf( '%s/%s', $this->cropsFolder, basename( $path ) );

        }

        if ($path == $this->originalImagePath) {
            throw new \Exception( 'You are not allowed to overwrite original image. Select another save path.' );
        }

        // var_dump( $path );
        $returnValue = parent::save( $path );

        // Reset
        $this->reset();

        // Return $this-> from parent
        return $returnValue;
    }
566751
public function loadImage(string $file, string $path = '') : AbstractResize
    {
        if (file_exists($path . $file) === true) {
            $this->source['path'] = $path;
            $this->source['file'] = $file;
            $this->sourceProperties();
        } else {
            throw new \Exception("File couldn't be found in supplied destination: '" . $path . $file . "'");
        }

        // Reset the processed status when a new image is loaded
        $this->processed = false;
        $this->file = null;
        $this->path = null;

        return $this;
    }
907515
public static function getViewContent($path) {
        if ($path === false) {
            throw new \Exception('The view file is not specified. Probably the correct path to the file was not found. Make sure that all paths are specified correctly, the files exists and is available.');
        }

        ob_start();

        require($path);

        $result = ob_get_contents();

        ob_end_clean();

        return $result;
    }
371287
public function loadFrom($path)
    {
        // Avoid repeat load of broken images
        $hash = sha1($path);
        if ($this->hasFailed($hash, null)) {
            return $this;
        }

        // Handle resource
        $error = self::FAILED_UNKNOWN;
        try {
            $this->setImageResource($this->getImageManager()->make($path));
            $this->markSuccess($hash, null);
            $error = null;
        } catch (NotReadableException $ex) {
            // Handle unsupported image encoding on load (will be marked as failed)
            // Unsupported exceptions are handled without being raised as exceptions
            $error = self::FAILED_INVALID;
        } finally {
            if ($error) {
                $this->markFailed($hash, null, $error);
            }
        }

        return $this;
    }
90965
public function getCollectionAsset($path)
    {
        if (!is_string($path)) {
            throw new Exception\RuntimeException(
                'Asset should be of type string. got ' . gettype($path)
            );
        }

        $asset = $this->resolveFile($path);

        if (empty($asset)) {
            throw new Exception\RuntimeException(
                'Unable to locate file: '.$path
            );
        }

        $this->getAssetFilterManager()->setFilters($path, $asset);

        return $asset;
    }
945966
public function setRuntimePath($path)
    {
        if (($runtimePath = realpath($path)) === false || !is_dir($runtimePath) || !is_writable($runtimePath)) {
            throw new Exception(Mindy::t('base', 'Application runtime path "{path}" is not valid. Please make sure it is a directory writable by the Web server process.', ['{path}' => $path]));
        }
        $this->_runtimePath = $runtimePath;
    }
1343318
public function write( $path, $content )
	{
		try {
			$this->fs->put( $path, $content );
		} catch( \Exception $e ) {
			throw new Exception( $e->getMessage(), 0, $e );
		}
	}
518030
public static function check($path)
	{
		if (strpos($path, '..') !== false)
		{
			throw new \Exception('JPath::check Use of relative paths not permitted', 20);
		}

		$path = self::clean($path);

		if ((JPATH_ROOT != '') && strpos($path, self::clean(JPATH_ROOT)) !== 0)
		{
			throw new \Exception('JPath::check Snooping out of bounds @ ' . $path, 20);
		}

		return $path;
	}
575414
public function setDictionaryFromFile( $path ) {
    if ( file_exists( $path ) ) {
      $dict = include $path;
      if( is_array($dict) ) {
        $this->dictionary = $dict;
        $this->fillDictionaryWords();
        return $this;
      }
      throw new \Exception('The file content must be an array!');
    }
    throw new \Exception('File not found in ' . $path );
  }