PHP 在symfony下修改ImageMagick sfThumbnail插件

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP 在symfony下修改ImageMagick sfThumbnail插件相关的知识,希望对你有一定的参考价值。

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;
        }

以上是关于PHP 在symfony下修改ImageMagick sfThumbnail插件的主要内容,如果未能解决你的问题,请参考以下文章