function ScaleDown($maxSize)
    {
        
        $height = $this->Height();
        $width = $this->Width();
        
        if ($width < $maxSize && $height < $maxSize)
            return;
        
        $xRatio = $maxSize / $height ;
        $yRatio = $maxSize / $width;
        
        $this->ScaleProportional(min($xRatio, $yRatio));
    }