original_string: public function scaleResize($width, $height) {
  
          // calculate source coordinates
          $kw = $this->width() / $width;
          $kh = $this->height() / $height;
          if($kh < $kw) {
              $src_h = $this->height();
              $src_y = 0;
              $src_w = round($kh * $width);
              $src_x = round(($this->width() - $src_w) / 2);
          } else {
              $src_h = round($kh * $height);
              $src_y = round(($this->height() - $src_h) / 2);
              $src_w = $this->width();
              $src_x = 0;
          }
  
          // copy new image
          $new = imagecreatetruecolor($width, $height);
          imagecopyresampled($new, $this->resource, 0, 0, $src_x, $src_y,
              $width, $height, $src_w, $src_h);
          $this->resource = $new;
  
          // for method chaining
          return $this;
      }
code: public function scaleResize($width, $height) {
  
          // calculate source coordinates
          $kw = $this->width() / $width;
          $kh = $this->height() / $height;
          if($kh < $kw) {
              $src_h = $this->height();
              $src_y = 0;
              $src_w = round($kh * $width);
              $src_x = round(($this->width() - $src_w) / 2);
          } else {
              $src_h = round($kh * $height);
              $src_y = round(($this->height() - $src_h) / 2);
              $src_w = $this->width();
              $src_x = 0;
          }
  
          // copy new image
          $new = imagecreatetruecolor($width, $height);
          imagecopyresampled($new, $this->resource, 0, 0, $src_x, $src_y,
              $width, $height, $src_w, $src_h);
          $this->resource = $new;
  
          // for method chaining
          return $this;
      }
code_tokens: public function scaleResize ( $ width , $ height ) { // calculate source coordinates $ kw = $ this -> width ( ) / $ width ; $ kh = $ this -> height ( ) / $ height ; if ( $ kh < $ kw ) { $ src_h = $ this -> height ( ) ; $ src_y = 0 ; $ src_w = round ( $ kh * $ width ) ; $ src_x = round ( ( $ this -> width ( ) - $ src_w ) / 2 ) ; } else { $ src_h = round ( $ kh * $ height ) ; $ src_y = round ( ( $ this -> height ( ) - $ src_h ) / 2 ) ; $ src_w = $ this -> width ( ) ; $ src_x = 0 ; } // copy new image $ new = imagecreatetruecolor ( $ width , $ height ) ; imagecopyresampled ( $ new , $ this -> resource , 0 , 0 , $ src_x , $ src_y , $ width , $ height , $ src_w , $ src_h ) ; $ this -> resource = $ new ; // for method chaining return $ this ; }
docstring: Resize image correctly scaled and than crop
  the necessary area
  
  @param int $width New width
  @param int $height New height
docstring_tokens: Resize image correctly scaled and than crop the necessary area