Changeset 10386 for extensions/square_thumbnails/trunk
- Timestamp:
- Apr 15, 2011, 4:41:51 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/square_thumbnails/trunk/functions.inc.php
r9953 r10386 259 259 $image = new Imagick($source_filepath); 260 260 261 $rotation = get_rotation_angle($source_filepath);262 263 261 // width/height 264 262 $source_width = $image->getImageWidth(); 265 263 $source_height = $image->getImageHeight(); 266 264 267 $coord = process_ratio($source_width, $source_height , $rotation);265 $coord = process_ratio($source_width, $source_height); 268 266 269 267 $image->cropImage($source_width, $source_height, $coord['x'], $coord['y']); 270 268 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); 272 270 273 271 // testing on height is useless in theory: if width is unchanged, there … … 292 290 $image->resizeImage($resize_dimensions['width'], $resize_dimensions['height'], Imagick::FILTER_LANCZOS, 0.9); 293 291 294 if (isset($rotation))295 {296 $image->rotateImage(new ImagickPixel(), -$rotation);297 $image->setImageOrientation(Imagick::ORIENTATION_TOPLEFT);298 }299 300 292 $image->writeImage($destination_filepath); 301 293 $image->destroy(); … … 305 297 } 306 298 307 function process_ratio(&$source_width, &$source_height , $rotation=null)299 function process_ratio(&$source_width, &$source_height) 308 300 { 309 301 global $conf; … … 318 310 $y = 0; 319 311 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']) 324 313 list($widthRatio, $heightRatio) = explode(':', $conf['thumbnails_ratio']); 325 314 … … 332 321 if($dest_ratio > $img_ratio) 333 322 { 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; 337 326 } 338 327 elseif ($dest_ratio < $img_ratio) 339 328 { 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; 343 332 } 344 333
Note: See TracChangeset
for help on using the changeset viewer.