Changeset 1502
- Timestamp:
- 05/31/10 15:37:28 (3 years ago)
- Location:
- plugins/apostrophePlugin/branches/features/cropping/lib
- Files:
-
- 3 modified
-
action/BaseaMediaBackendActions.class.php (modified) (3 diffs)
-
toolkit/aImageConverter.class.php (modified) (1 diff)
-
toolkit/aMediaRouting.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
plugins/apostrophePlugin/branches/features/cropping/lib/action/BaseaMediaBackendActions.class.php
r1255 r1502 39 39 array_keys(aMediaItemTable::$mimeTypes))); 40 40 $this->forward404Unless(($resizeType !== 'c') || ($resizeType !== 's')); 41 $output = $this->getDirectory() . 42 DIRECTORY_SEPARATOR . "$slug.$width.$height.$resizeType.$format"; 41 // EDITED FOR ARBITRARY CROPPING 42 $cropLeft = $request->getParameter('cropLeft'); 43 $cropTop = $request->getParameter('cropTop'); 44 $cropWidth = $request->getParameter('cropWidth'); 45 $cropHeight = $request->getParameter('cropHeight'); 46 47 if (!is_null($cropWidth) && !is_null($cropHeight) && !is_null($cropLeft) && !is_null($cropTop)) 48 { 49 $cropLeft = ceil($cropLeft + 0); 50 $cropTop = ceil($cropTop + 0); 51 $cropWidth = ceil($cropWidth + 0); 52 $cropHeight = ceil($cropHeight + 0); 53 $resizeType = 'c'; 54 55 $output = $this->getDirectory() . 56 DIRECTORY_SEPARATOR . "$slug.$width.$height.$cropLeft.$cropTop.$cropWidth.$cropHeight.$resizeType.$format"; 57 } 58 else 59 { 60 $cropLeft = null; 61 $cropTop = null; 62 $cropWidth = null; 63 $cropHeight = null; 64 $output = $this->getDirectory() . 65 DIRECTORY_SEPARATOR . "$slug.$width.$height.$resizeType.$format"; 66 } 67 43 68 // If .htaccess has not been set up, or we are not running 44 69 // from the default front controller, then we may get here … … 57 82 $method = 'scaleToFit'; 58 83 } 59 $quality = sfConfig::get('app_aMedia_jpeg_quality', 75);60 84 aImageConverter::$method( 61 85 aMediaItemTable::getDirectory() . … … 65 89 $width, 66 90 $height, 67 sfConfig::get('app_aMedia_jpeg_quality', 75)); 91 sfConfig::get('app_aMedia_jpeg_quality', 75), 92 $cropLeft, 93 $cropTop, 94 $cropWidth, 95 $cropHeight); 68 96 } 69 97 // The FIRST time, we output this here. Later it -
plugins/apostrophePlugin/branches/features/cropping/lib/toolkit/aImageConverter.class.php
r1499 r1502 347 347 $width = $scaleParameters['xysize'][0]; 348 348 $height = $scaleParameters['xysize'][1]; 349 // This was backwards until 05/31/2010, making things bigger rather than smaller if their 350 // aspect ratios differed from the original. Be consistent with netpbm which makes things 351 // smaller not bigger 349 352 if (($width / $height) > ($swidth / $sheight)) 350 353 { 351 // Wider than the original. So it will be shorter than requested352 $ height = ceil($width * ($sheight / $swidth));354 // Wider than the original. So it will be narrower than requested 355 $width = ceil($height * ($swidth / $sheight)); 353 356 } 354 357 else 355 358 { 356 // Taller than the original. So it will be narrower than requested357 $ width = ceil($height * ($swidth / $sheight));359 // Taller than the original. So it will be shorter than requested 360 $height = ceil($width * ($sheight / $swidth)); 358 361 } 359 362 $out = self::createTrueColorAlpha($width, $height); -
plugins/apostrophePlugin/branches/features/cropping/lib/toolkit/aMediaRouting.php
r883 r1502 26 26 'action' => 'original' 27 27 ), array('slug' => '^' . aTools::getSlugRegexpFragment() . '$', 'format' => '^(jpg|png|gif|pdf)$'))); 28 29 $route = new sfRoute('/uploads/media_items/:slug.:width.:height.:cropLeft.:cropTop.:cropWidth.:cropHeight.:resizeType.:format', array( 30 'module' => 'aMediaBackend', 31 'action' => 'image' 32 ), array( 33 'slug' => '^' . aTools::getSlugRegexpFragment() . '$', 34 'width' => '^\d+$', 35 'height' => '^\d+$', 36 'cropLeft' => '^\d+$', 37 'cropTop' => '^\d+$', 38 'cropWidth' => '^\d+$', 39 'cropHeight' => '^\d+$', 40 'resizeType' => '^\w$', 41 'format' => '^(jpg|png|gif)$' 42 )); 43 $r->prependRoute('a_media_image_cropped', $route); 28 44 29 45 $route = new sfRoute('/uploads/media_items/:slug.:width.:height.:resizeType.:format', array(

