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);
    }