public function save($path, $type = null)
    {
        #imagepng() - Output a PNG image to either the browser or a file
        #imagegif() - Output image to browser or file
        #imagewbmp() - Output image to browser or file
        #imagejpeg() - Output image to browser or file
        
        if (!$type) {
            $type = $this->type;
        }

        switch ($type) {
            case 'gif':
                imagegif($this->resource, $path);
                break;
            case 'png':
                $quality = (100 - $this->quality) / 10;

                if ($quality > 9) {
                    $quality = 9;
                }

                imagepng($this->resource, $path, $quality);
                break;
            case 'bmp':
            case 'wbmp':
                imagewbmp($this->resource, $path, $this->quality);
                break;
            case 'jpg':
            case 'jpeg':
            case 'pjpeg':
            default:
                imagejpeg($this->resource, $path, $this->quality);
                break;

        }

        return $this;
    }