Example #1
0
 public function resize($maxwidth = 150, $maxheight = 150, $scale = true)
 {
     if (!$scale) {
         $width = $maxwidth;
         $height = $maxheight;
     } else {
         if ($this->width() < $maxwidth && $this->height() < $maxheight) {
             $width = $this->width();
             $height = $this->height();
         } else {
             if ($this->width() < $this->height()) {
                 $height = $maxheight;
                 $width = round($this->width() * $height / $this->height());
             } else {
                 $width = $maxwidth;
                 $height = round($this->height() * $width / $this->width());
             }
         }
     }
     $new = new self();
     $new->createtruecolor($width, $height);
     $new->preparecopy($this);
     $new->copyresampled($this->handle(), 0, 0, 0, 0, $width, $height, $this->width(), $this->height());
     $this->sethandle($new->handle());
     return $this;
 }