protected function readImage()
    {
        // set default path
        $path = $this->pathFile;

        // handle caching
        if (!empty($this->pathCache)) {
            // write / refresh cache file if necessary
            if (!$this->isCached()) {
                $this->writeCache();
            }

            // replace path if file is cached
            if ($this->isCached()) {
                $path = $this->pathCache;
            }

        }

        // get image information
        $read = @getimagesize($path);
        if (false === $read) {
            throw new \RuntimeException(
                sprintf(
                    "Couldn't read image at %s",
                    $path
                )
            );
        }

        // detect image type
        switch ($read[2]) {
            case IMAGETYPE_GIF:
                $this->image = @imagecreatefromgif($path);
                break;

            case IMAGETYPE_JPEG:
                $this->image = @imagecreatefromjpeg($path);
                break;

            case IMAGETYPE_PNG:
                $this->image = @imagecreatefrompng($path);
                break;

            default:
                // image type not supported
                throw new \UnexpectedValueException(
                    sprintf(
                        'Image type %s not supported',
                        image_type_to_mime_type($read[2])
                    )
                );
        }

        if (false === $this->image) {
            throw new \RuntimeException(
                sprintf(
                    "Couldn't read image at %s",
                    $path
                )
            );
        }

        // set image dimensions
        $this->width = $read[0];
        $this->height = $read[1];

        // set mime type
        $this->mimeType = $read['mime'];

        // set modified date
        $this->modified = @filemtime($path);
    }
protected function readImage()
    {
        // set default path
        $path = $this->pathFile;

        // handle caching
        if (!empty($this->pathCache)) {
            // write / refresh cache file if necessary
            if (!$this->isCached()) {
                $this->writeCache();
            }

            // replace path if file is cached
            if ($this->isCached()) {
                $path = $this->pathCache;
            }

        }

        // get image information
        $read = @getimagesize($path);
        if (false === $read) {
            throw new \RuntimeException(
                sprintf(
                    "Couldn't read image at %s",
                    $path
                )
            );
        }

        // detect image type
        switch ($read[2]) {
            case IMAGETYPE_GIF:
                $this->image = @imagecreatefromgif($path);
                break;

            case IMAGETYPE_JPEG:
                $this->image = @imagecreatefromjpeg($path);
                break;

            case IMAGETYPE_PNG:
                $this->image = @imagecreatefrompng($path);
                break;

            default:
                // image type not supported
                throw new \UnexpectedValueException(
                    sprintf(
                        'Image type %s not supported',
                        image_type_to_mime_type($read[2])
                    )
                );
        }

        if (false === $this->image) {
            throw new \RuntimeException(
                sprintf(
                    "Couldn't read image at %s",
                    $path
                )
            );
        }

        // set image dimensions
        $this->width = $read[0];
        $this->height = $read[1];

        // set mime type
        $this->mimeType = $read['mime'];

        // set modified date
        $this->modified = @filemtime($path);
    }
protected function readImage ( ) { // set default path $ path = $ this -> pathFile ; // handle caching if ( ! empty ( $ this -> pathCache ) ) { // write / refresh cache file if necessary if ( ! $ this -> isCached ( ) ) { $ this -> writeCache ( ) ; } // replace path if file is cached if ( $ this -> isCached ( ) ) { $ path = $ this -> pathCache ; } } // get image information $ read = @ getimagesize ( $ path ) ; if ( false === $ read ) { throw new \ RuntimeException ( sprintf ( "Couldn't read image at %s" , $ path ) ) ; } // detect image type switch ( $ read [ 2 ] ) { case IMAGETYPE_GIF : $ this -> image = @ imagecreatefromgif ( $ path ) ; break ; case IMAGETYPE_JPEG : $ this -> image = @ imagecreatefromjpeg ( $ path ) ; break ; case IMAGETYPE_PNG : $ this -> image = @ imagecreatefrompng ( $ path ) ; break ; default : // image type not supported throw new \ UnexpectedValueException ( sprintf ( 'Image type %s not supported' , image_type_to_mime_type ( $ read [ 2 ] ) ) ) ; } if ( false === $ this -> image ) { throw new \ RuntimeException ( sprintf ( "Couldn't read image at %s" , $ path ) ) ; } // set image dimensions $ this -> width = $ read [ 0 ] ; $ this -> height = $ read [ 1 ] ; // set mime type $ this -> mimeType = $ read [ 'mime' ] ; // set modified date $ this -> modified = @ filemtime ( $ path ) ; }
Reads the image file.

@return void

@throws \RuntimeException Thrown if the image could not be processed.
@throws \UnexpectedValueException Thrown if the image type is not supported.
Reads the image file .