Image.php
public function cacheFile($type = 'jpg', $quality = 80, $actual = false)
    {
        if ($type == 'guess') {
            $type = $this->guessType();
        }

        if (!count($this->operations) && $type == $this->guessType() && !$this->forceCache) {
            return $this->getFilename($this->getFilePath());
        }

        // Computes the hash
        $this->hash = $this->getHash($type, $quality);

        // Generates the cache file
        $cacheFile = '';

        if (!$this->prettyName || $this->prettyPrefix) {
            $cacheFile .= $this->hash;
        }

        if ($this->prettyPrefix) {
            $cacheFile .= '-';
        }

        if ($this->prettyName) {
            $cacheFile .= $this->prettyName;
        }

        $cacheFile .= '.'.$type;

        // If the files does not exists, save it
        $image = $this;

        // Target file should be younger than all the current image
        // dependencies
        $conditions = array(
            'younger-than' => $this->getDependencies(),
        );

        // The generating function
        $generate = function ($target) use ($image, $type, $quality) {
            $result = $image->save($target, $type, $quality);

            if ($result != $target) {
                throw new GenerationError($result);
            }
        };

        // Asking the cache for the cacheFile
        try {
            $file = $this->getCacheSystem()->getOrCreateFile($cacheFile, $conditions, $generate, $actual);
        } catch (GenerationError $e) {
            $file = $e->getNewFile();
        }

        // Nulling the resource
        $this->getAdapter()->setSource(new Source\File($file));
        $this->getAdapter()->deinit();

        if ($actual) {
            return $file;
        } else {
            return $this->getFilename($file);
        }
    }
public function cacheFile($type = 'jpg', $quality = 80, $actual = false)
    {
        if ($type == 'guess') {
            $type = $this->guessType();
        }

        if (!count($this->operations) && $type == $this->guessType() && !$this->forceCache) {
            return $this->getFilename($this->getFilePath());
        }

        // Computes the hash
        $this->hash = $this->getHash($type, $quality);

        // Generates the cache file
        $cacheFile = '';

        if (!$this->prettyName || $this->prettyPrefix) {
            $cacheFile .= $this->hash;
        }

        if ($this->prettyPrefix) {
            $cacheFile .= '-';
        }

        if ($this->prettyName) {
            $cacheFile .= $this->prettyName;
        }

        $cacheFile .= '.'.$type;

        // If the files does not exists, save it
        $image = $this;

        // Target file should be younger than all the current image
        // dependencies
        $conditions = array(
            'younger-than' => $this->getDependencies(),
        );

        // The generating function
        $generate = function ($target) use ($image, $type, $quality) {
            $result = $image->save($target, $type, $quality);

            if ($result != $target) {
                throw new GenerationError($result);
            }
        };

        // Asking the cache for the cacheFile
        try {
            $file = $this->getCacheSystem()->getOrCreateFile($cacheFile, $conditions, $generate, $actual);
        } catch (GenerationError $e) {
            $file = $e->getNewFile();
        }

        // Nulling the resource
        $this->getAdapter()->setSource(new Source\File($file));
        $this->getAdapter()->deinit();

        if ($actual) {
            return $file;
        } else {
            return $this->getFilename($file);
        }
    }
public function cacheFile ( $ type = 'jpg' , $ quality = 80 , $ actual = false ) { if ( $ type == 'guess' ) { $ type = $ this -> guessType ( ) ; } if ( ! count ( $ this -> operations ) && $ type == $ this -> guessType ( ) && ! $ this -> forceCache ) { return $ this -> getFilename ( $ this -> getFilePath ( ) ) ; } // Computes the hash $ this -> hash = $ this -> getHash ( $ type , $ quality ) ; // Generates the cache file $ cacheFile = '' ; if ( ! $ this -> prettyName || $ this -> prettyPrefix ) { $ cacheFile .= $ this -> hash ; } if ( $ this -> prettyPrefix ) { $ cacheFile .= '-' ; } if ( $ this -> prettyName ) { $ cacheFile .= $ this -> prettyName ; } $ cacheFile .= '.' . $ type ; // If the files does not exists, save it $ image = $ this ; // Target file should be younger than all the current image // dependencies $ conditions = array ( 'younger-than' => $ this -> getDependencies ( ) , ) ; // The generating function $ generate = function ( $ target ) use ( $ image , $ type , $ quality ) { $ result = $ image -> save ( $ target , $ type , $ quality ) ; if ( $ result != $ target ) { throw new GenerationError ( $ result ) ; } } ; // Asking the cache for the cacheFile try { $ file = $ this -> getCacheSystem ( ) -> getOrCreateFile ( $ cacheFile , $ conditions , $ generate , $ actual ) ; } catch ( GenerationError $ e ) { $ file = $ e -> getNewFile ( ) ; } // Nulling the resource $ this -> getAdapter ( ) -> setSource ( new Source \ File ( $ file ) ) ; $ this -> getAdapter ( ) -> deinit ( ) ; if ( $ actual ) { return $ file ; } else { return $ this -> getFilename ( $ file ) ; } }
Gets the cache file name and generate it if it does not exists.
Note that if it exists, all the image computation process will
not be done.

@param string $type    the image type
@param int    $quality the quality (for JPEG)
Gets the cache file name and generate it if it does not exists . Note that if it exists all the image computation process will not be done .