lib/ShortPixel/Source.php
public function fromFolder($path, $maxFiles = 0, $exclude = array(), $persistFolder = false, $maxTotalFileSize = ShortPixel::CLIENT_MAX_BODY_SIZE, $recurseDepth = PHP_INT_MAX) {
        if($maxFiles == 0) {
            $maxFiles = ShortPixel::MAX_ALLOWED_FILES_PER_CALL;
        }
        //sanitize
        $maxFiles = max(1, min(ShortPixel::MAX_ALLOWED_FILES_PER_CALL, intval($maxFiles)));

        $persister = ShortPixel::getPersister($path);
        if(!$persister) {
            throw new PersistException("Persist is not enabled in options, needed for folder optimization");
        }
        $paths = $persister->getTodo($path, $maxFiles, $exclude, $persistFolder, $maxTotalFileSize, $recurseDepth);
        if($paths) {
            ShortPixel::setOptions(array("base_source_path" => $path));
            return $this->fromFiles($paths->files, null, $paths->filesPending);
        }
        throw new ClientException("Couldn't find any processable file at given path ($path).", 2);
    }
public function fromFolder($path, $maxFiles = 0, $exclude = array(), $persistFolder = false, $maxTotalFileSize = ShortPixel::CLIENT_MAX_BODY_SIZE, $recurseDepth = PHP_INT_MAX) {
        if($maxFiles == 0) {
            $maxFiles = ShortPixel::MAX_ALLOWED_FILES_PER_CALL;
        }
        //sanitize
        $maxFiles = max(1, min(ShortPixel::MAX_ALLOWED_FILES_PER_CALL, intval($maxFiles)));

        $persister = ShortPixel::getPersister($path);
        if(!$persister) {
            throw new PersistException("Persist is not enabled in options, needed for folder optimization");
        }
        $paths = $persister->getTodo($path, $maxFiles, $exclude, $persistFolder, $maxTotalFileSize, $recurseDepth);
        if($paths) {
            ShortPixel::setOptions(array("base_source_path" => $path));
            return $this->fromFiles($paths->files, null, $paths->filesPending);
        }
        throw new ClientException("Couldn't find any processable file at given path ($path).", 2);
    }
public function fromFolder ( $ path , $ maxFiles = 0 , $ exclude = array ( ) , $ persistFolder = false , $ maxTotalFileSize = ShortPixel :: CLIENT_MAX_BODY_SIZE , $ recurseDepth = PHP_INT_MAX ) { if ( $ maxFiles == 0 ) { $ maxFiles = ShortPixel :: MAX_ALLOWED_FILES_PER_CALL ; } //sanitize $ maxFiles = max ( 1 , min ( ShortPixel :: MAX_ALLOWED_FILES_PER_CALL , intval ( $ maxFiles ) ) ) ; $ persister = ShortPixel :: getPersister ( $ path ) ; if ( ! $ persister ) { throw new PersistException ( "Persist is not enabled in options, needed for folder optimization" ) ; } $ paths = $ persister -> getTodo ( $ path , $ maxFiles , $ exclude , $ persistFolder , $ maxTotalFileSize , $ recurseDepth ) ; if ( $ paths ) { ShortPixel :: setOptions ( array ( "base_source_path" => $ path ) ) ; return $ this -> fromFiles ( $ paths -> files , null , $ paths -> filesPending ) ; } throw new ClientException ( "Couldn't find any processable file at given path ($path)." , 2 ) ; }
processes a chunk of MAX_ALLOWED files from the folder, based on the persisted information about which images are processed and which not. This information is offered by the Persister object.
@param $path - the folder path on the local drive
@param int $maxFiles - maximum number of files to select from the folder
@param array $exclude - exclude files based on regex patterns
@param bool $persistFolder - the path where to store the metadata, if different from the $path (usually the target path)
@param int $maxTotalFileSize - max summed up file size in MB
@param int $recurseDepth - how many subfolders deep to go. Defaults to PHP_INT_MAX
@return Commander - the class that handles the optimization commands
@throws ClientException
@throws PersistException
processes a chunk of MAX_ALLOWED files from the folder based on the persisted information about which images are processed and which not . This information is offered by the Persister object .