Return to Snippet

Revision: 8221
at September 9, 2008 08:31 by catchamonkey


Initial Code
Change lines 223-237:

    $width  = $this->sourceWidth;
    $height = $this->sourceHeight;
    $x = $y = 0;
    switch (@$this->options['method']) {
      case "shave_all":
        if ($width > $height)
        {
          $x = ceil(($width - $height) / 2 );
          $width = $height;
        }
        elseif ($height > $width)
        {
          $y = ceil(($height - $width) / 2);
          $height = $width;
        }

to:

    $width  = $this->sourceWidth;
    $height = $this->sourceHeight;
    $mWidth = $this->maxWidth;
    $mHeight = $this->maxHeight;
    $x = $y = 0;
    switch (@$this->options['method']) {
      case "shave_all":
        if ($width > $height)
        {
          $x = ceil(($width - ($height*$mWidth)/$mHeight) / 2 );
          $width = $height;
        }
        elseif ($height > $width)
        {
          $y = ceil(($height - $width*($mHeight/$mWidth)) / 2);
          $height = $width;
        }

Initial URL

                                

Initial Description
The plugin's "shave_all" function was not properly cropping and resizing the thumbnails for me. The following needs to be changed in sfImageMagickAdapter.class.php

Initial Title
ImageMagick sfThumbnail Plugin fix under symfony

Initial Tags
plugin

Initial Language
PHP