/**
  * Construct a new Resizer instance
  *
  * @param sfImagePoolImage $image 
  * @param string $method "crop" or "scale" 
  * @param integer $width 
  * @param integer $height 
  */
 public function __construct(sfImagePoolImage $image, $method, $width, $height)
 {
     $this->checkMethod($method);
     // expected values for method are 'scale' and 'crop', see plugin routing.yml
     // for default values.
     $this->image = $image;
     $this->method = $method;
     $this->scale = $method == 'scale' ? true : false;
     $default_options = sfConfig::get('app_sf_image_pool_adapter_options', array());
     $options = $this->scale ? array() : array('method' => 'shave_all');
     $this->options = array_merge($default_options, $options);
     $this->width = $width;
     $this->height = $height;
     // This is a tad clunky - we just want to return the params passed to
     // sfThumbnail, but we can't use call_user_func_array to call a
     // constructor. Reflection to the rescue!
     // http://www.php.net/manual/en/function.call-user-func-array.php#74427
     $this->params = array($this->width, $this->height, $this->scale, sfConfig::get('app_sf_image_pool_inflate', true), sfConfig::get('app_sf_image_pool_jpeg_quality', 90), sfConfig::get('app_image_pool_adapter', 'ImagePoolImageMagickAdapter'), $this->options);
     $reflectionObj = new ReflectionClass('sfThumbnail');
     $this->thumb = $reflectionObj->newInstanceArgs($this->params);
     $this->thumb->loadFile($this->image->getPathToOriginalFile());
 }
 public static function calculateWidthAndHeight(sfImagePoolImage $image, $w, $h)
 {
     $sfthumb = new sfThumbnail($w, $h, true, sfConfig::get('app_sf_image_pool_inflate', true));
     $sfthumb->loadFile($image->getPathToOriginalFile());
     $response = array($sfthumb->getThumbWidth(), $sfthumb->getThumbHeight());
     unset($sfthumb);
     return $response;
 }