public function resizeToWidth($wid)
{
$scale = $wid / $this->width;
$hgt = round($this->height * $scale);
// Create a new image output resource.
$this->createResource();
$this->output = imagecreatetruecolor($wid, $hgt);
// Copy newly sized image to the output resource.
$this->copyImage($wid, $hgt);
return $this;
}