Development

Changeset 11081 for plugins/sfThumbnailPlugin

You must first sign up to be able to contribute.

Show
Ignore:
Timestamp:
08/24/08 14:28:26 (5 years ago)
Author:
kupokomapa
Message:

[sfThumbnailPlugin] Added a new method to sfImagemagickAdapter for dealing with custom crop proportions. Releasing version 1.5.3

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/sfThumbnailPlugin/lib/sfImageMagickAdapter.class.php

    r10909 r11081  
    170170  } 
    171171 
    172   public function toResource() 
    173   { 
    174     throw new Exception('The ImageMagick adapter does not support the toResource method.'); 
    175   } 
    176  
    177172  public function loadFile($thumbnail, $image) 
    178173  { 
     
    229224    $height = $this->sourceHeight; 
    230225    $x = $y = 0; 
    231     switch (@$this->options['method']) { 
     226    switch (@$this->options['method'])  
     227    { 
    232228      case "shave_all": 
    233         if ($width > $height) 
    234         { 
    235           $x = ceil(($width - $height) / 2 ); 
    236           $width = $height; 
    237         } 
    238         elseif ($height > $width) 
    239         { 
    240           $y = ceil(($height - $width) / 2); 
    241           $height = $width; 
     229        $proportion['source'] = $width / $height; 
     230        $proportion['thumb'] = $thumbnail->getThumbWidth() / $thumbnail->getThumbHeight(); 
     231         
     232        if ($proportion['source'] > 1 && $proportion['thumb'] < 1) 
     233        { 
     234          $x = ($width - $height * $proportion['thumb']) / 2; 
     235        } 
     236        else 
     237        { 
     238          if ($proportion['source'] > $proportion['thumb']) 
     239          { 
     240            $x = ($width - $height * $proportion['thumb']) / 2; 
     241          } 
     242          else 
     243          { 
     244            $y = ($height - $width / $proportion['thumb']) / 2; 
     245          } 
    242246        } 
    243247 
    244248        $command = sprintf(" -shave %dx%d", $x, $y); 
    245249        break; 
     250 
    246251      case "shave_bottom": 
    247252        if ($width > $height) 
     
    282287 
    283288        break; 
     289      case 'custom': 
     290        $coords = $this->options['coords']; 
     291        if (empty($coords)) break; 
     292         
     293        $x = $coords['x1']; 
     294        $y = $coords['y1']; 
     295        $width = $coords['x2'] - $coords['x1']; 
     296        $height = $coords['y2'] - $coords['y1']; 
     297         
     298        if (is_null($thumbDest)) 
     299        { 
     300          $command = sprintf( 
     301            " -crop %dx%d+%d+%d %s '-' | %s", 
     302            $width, $height, 
     303            $x, $y, 
     304            escapeshellarg($this->image), 
     305            $this->magickCommands['convert'] 
     306          ); 
     307 
     308          $this->image = '-'; 
     309        } 
     310        else 
     311        { 
     312          $command = sprintf( 
     313            " -crop %dx%d+%d+%d %s %s && %s", 
     314            $width, $height, 
     315            $x, $y, 
     316            escapeshellarg($this->image), escapeshellarg($thumbDest), 
     317            $this->magickCommands['convert'] 
     318          ); 
     319 
     320          $this->image = $thumbDest; 
     321        } 
     322        break; 
    284323    } // end switch 
    285324 
     
    293332    } 
    294333 
    295     if ($this->quality && $targetMime == 'image/jpeg') 
     334    if ($this->quality && $thumbnail->getMime() == 'image/jpeg') 
    296335    { 
    297336      $command .= ' -quality '.$this->quality.'% '; 
  • plugins/sfThumbnailPlugin/package.xml

    r7941 r11081  
    1111  <active>yes</active> 
    1212 </lead> 
    13  <date>2008-03-17</date> 
     13 <date>2008-08-23</date> 
    1414 <time>22:10:00</time> 
    1515 <version> 
    16   <release>1.5.1</release> 
     16  <release>1.5.3</release> 
    1717  <api>1.0.0</api> 
    1818 </version> 
     
    2727   <file md5sum="ade44239bce430f61f7c0c8cd1ce89b0" name="lib/sfThumbnail.class.php" role="data" /> 
    2828   <file md5sum="ea7aec8b4be6212af8434f65efa85a69" name="lib/sfGDAdapter.class.php" role="data" /> 
    29    <file md5sum="add9e55ed76cc8d607b11bf2a4704aea" name="lib/sfImageMagickAdapter.class.php" role="data" /> 
    30    <file md5sum="83736fac123e0add1a22078df8fa8541" name="lib/helper/sfThumbnailHelper.php" role="data" /> 
     29   <file md5sum="ce521588909d175f90f116e9a9500935" name="lib/sfImageMagickAdapter.class.php" role="data" /> 
    3130   <file md5sum="c5de5dccc5785beae22f92424d51cad6" name="README" role="data" /> 
    3231   <file md5sum="c0ab88a4687e9ff8e0fb6c95ca49ed74" name="LICENSE" role="data" />