- Timestamp:
- 08/08/10 12:18:34 (22 months ago)
- Location:
- plugins/apostrophePlugin/trunk
- Files:
-
- 2 modified
-
. (modified) (1 prop)
-
lib/toolkit/aImageConverter.class.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
plugins/apostrophePlugin/trunk
- Property svn:mergeinfo changed
-
plugins/apostrophePlugin/trunk/lib/toolkit/aImageConverter.class.php
r1872 r1917 55 55 } 56 56 57 static public function cropOriginal($fileIn, $fileOut, $width, $height, $quality = 75) 58 { 57 // $width and $height are the dimensions of the final rendered image. $quality is the JPEG quality setting (where needed). 58 // The $crop parameters, when not null (all four must be null or not null), are used to crop the original before scaling/distorting 59 // to the specified width and height and are always in the original image's coordinates. 60 61 // If cropping coordinates are not specified, the largest possible portion of the center of the original image is scaled to fit into the 62 // destination image without distortion 63 64 static public function cropOriginal($fileIn, $fileOut, $width, $height, $quality = 75, $cropLeft = null, $cropTop = null, $cropWidth = null, $cropHeight = null) 65 { 66 // Allow skipping of parameters 67 if (is_null($quality)) 68 { 69 $quality = 75; 70 } 59 71 $width = ceil($width); 60 72 $height = ceil($height); … … 67 79 $iratio = $iwidth / $iheight; 68 80 $ratio = $width / $height; 81 82 // Spike's contribution: arbitrary cropping 83 if (!is_null($cropWidth) && !is_null($cropHeight) && !is_null($cropLeft) && !is_null($cropTop)) 84 { 85 $cropTop = ceil($cropTop + 0); 86 $cropLeft = ceil($cropLeft + 0); 87 $cropWidth = ceil($cropWidth + 0); 88 $cropHeight = ceil($cropHeight + 0); 89 90 $scale = array('xysize' => array($width + 0, $height + 0)); 91 $crop = array('left' => $cropLeft, 'top' => $cropTop, 'width' => $cropWidth, 'height' => $cropHeight); 92 return self::scaleBody($fileIn, $fileOut, $scale, $crop, $quality); 93 } 69 94 70 95 $scale = array('xysize' => array($width + 0, $height + 0)); … … 356 381 $width = $scaleParameters['xysize'][0]; 357 382 $height = $scaleParameters['xysize'][1]; 358 383 // This was backwards until 05/31/2010, making things bigger rather than smaller if their 384 // aspect ratios differed from the original. Be consistent with netpbm which makes things 385 // smaller not bigger 359 386 if (($width / $height) > ($swidth / $sheight)) 360 387 { 361 // Wider than the original. So it will be shorter than requested362 $ height = ceil($width * ($sheight / $swidth));388 // Wider than the original. So it will be narrower than requested 389 $width = ceil($height * ($swidth / $sheight)); 363 390 } 364 391 else 365 392 { 366 // Taller than the original. So it will be narrower than requested367 $ width = ceil($height * ($swidth / $sheight));393 // Taller than the original. So it will be shorter than requested 394 $height = ceil($width * ($sheight / $swidth)); 368 395 } 369 396 $out = self::createTrueColorAlpha($width, $height);

