public function save($pathToFile = null, $type = null, $jpgQuality = null)
    {
        if ($pathToFile === null) $pathToFile = $this->pathToFile;
        if ($type === null) $type = $this->type;
        if ($jpgQuality === null) $jpgQuality = $this->jpgQuality;
        switch ($type) {
            case self::GIF:
                imagegif($this->resource, $pathToFile);
                break;
            case self::JPG:
                imagejpeg($this->resource, $pathToFile, $jpgQuality);
                break;
            case self::PNG:
                imagepng($this->resource, $pathToFile);
                break;
            case self::BMP:
                imagewbmp($this->resource, $pathToFile);
                break;
            default:
                throw new ImageException("Unknown type of file " . ($this->pathToFile) . ".", ImageException::UnsupportedFormatException);
                break;
        }
        $this->pathToFile = $pathToFile;
    }