Ignore:
Timestamp:
Apr 15, 2011, 4:41:51 PM (14 years ago)
Author:
patdenice
Message:

Minor bug corrected.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/square_thumbnails/trunk/functions.inc.php

    r9953 r10386  
    259259  $image = new Imagick($source_filepath);
    260260
    261   $rotation = get_rotation_angle($source_filepath);
    262  
    263261  // width/height
    264262  $source_width  = $image->getImageWidth();
    265263  $source_height = $image->getImageHeight();
    266264
    267   $coord = process_ratio($source_width, $source_height, $rotation);
     265  $coord = process_ratio($source_width, $source_height);
    268266
    269267  $image->cropImage($source_width, $source_height, $coord['x'], $coord['y']);
    270268 
    271   $resize_dimensions = get_resize_dimensions($source_width, $source_height, $max_width, $max_height, $rotation);
     269  $resize_dimensions = get_resize_dimensions($source_width, $source_height, $max_width, $max_height);
    272270
    273271  // testing on height is useless in theory: if width is unchanged, there
     
    292290  $image->resizeImage($resize_dimensions['width'], $resize_dimensions['height'], Imagick::FILTER_LANCZOS, 0.9);
    293291
    294   if (isset($rotation))
    295   {
    296     $image->rotateImage(new ImagickPixel(), -$rotation);
    297     $image->setImageOrientation(Imagick::ORIENTATION_TOPLEFT);
    298   }
    299 
    300292  $image->writeImage($destination_filepath);
    301293  $image->destroy();
     
    305297}
    306298
    307 function process_ratio(&$source_width, &$source_height, $rotation=null)
     299function process_ratio(&$source_width, &$source_height)
    308300{
    309301  global $conf;
     
    318310  $y = 0;
    319311
    320   if (!$conf['thumbnails_ratio_orientation'] and in_array($rotation, array(90, 270)))
    321     list($heightRatio, $widthRatio) = explode(':', $conf['thumbnails_ratio']);
    322 
    323   elseif ($source_width >= $source_height or !$conf['thumbnails_ratio_orientation'])
     312  if ($source_width >= $source_height or !$conf['thumbnails_ratio_orientation'])
    324313    list($widthRatio, $heightRatio) = explode(':', $conf['thumbnails_ratio']);
    325314
     
    332321  if($dest_ratio > $img_ratio)
    333322  {
    334     $destHeight = ceil(($source_width * $heightRatio) / $widthRatio);
    335     $y = ceil(($source_height - $destHeight) / 2 );
    336     $source_height = $destHeight ;
     323    $destHeight = round($source_width * $heightRatio / $widthRatio);
     324    $y = round(($source_height - $destHeight) / 2 );
     325    $source_height = $destHeight;
    337326  }
    338327  elseif ($dest_ratio < $img_ratio)
    339328  {
    340     $destWidth = ceil(($source_height * $widthRatio) / $heightRatio);
    341     $x = ceil(($source_width - $destWidth) / 2 );
    342     $source_width = $destWidth ;
     329    $destWidth = round($source_height * $widthRatio / $heightRatio);
     330    $x = round(($source_width - $destWidth) / 2 );
     331    $source_width = $destWidth;
    343332  }
    344333
Note: See TracChangeset for help on using the changeset viewer.