To participate you must create an account on apostrophenow.org. If you have already done so, click Login.

Changeset 4458

Show
Ignore:
Timestamp:
01/05/12 20:35:32 (5 months ago)
Author:
tboutell
Message:

* Fixed [1212]: cropping type 'c' does not work properly with JPEGs that have an orientation other than landscape. Calling aImageConverter::getInfo() rather than getimagesize() does the trick.

* Added a new 'uncropped' option to the aSlideshowSlot/slideshow component. When 'uncropped' => true is specified, the uncropped originals of images are used instead of any user-cropped version. Normally this is not a good thing, but it may be helpful when you render the same slideshow in two ways, one of which accommodates user cropping well and one of which does not.

Location:
plugins/apostrophePlugin/branches/1.5/lib
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • plugins/apostrophePlugin/branches/1.5/lib/action/BaseaSlideshowSlotComponents.class.php

    r4378 r4458  
    2424    $this->setupOptions(); 
    2525    $this->getLinkedItems(); 
     26     
     27    if ($this->options['uncropped']) 
     28    { 
     29      $newItems = array(); 
     30      foreach ($this->items as $item) 
     31      { 
     32        $item = $item->getCropOriginal(); 
     33        $newItems[] = $item; 
     34      } 
     35      $this->items = $newItems; 
     36    } 
    2637     
    2738    if ($this->options['random'] && count($this->items)) 
     
    6677    $this->options['slideshowTemplate'] = $this->getOption('slideshowTemplate', 'slideshow'); 
    6778    $this->options['random'] = $this->getOption('random', false); 
     79    // Ignore any manual crops by the user. This is useful if you want to use 'c' in an 
     80    // alternative rendering of a slideshow where custom crops are normally welcome 
     81    $this->options['uncropped'] = $this->getOption('uncropped', false); 
    6882     
    6983    // We automatically set up the aspect ratio if the resizeType is set to 'c' 
  • plugins/apostrophePlugin/branches/1.5/lib/toolkit/aImageConverter.class.php

    r4341 r4458  
    100100  static public function cropOriginal($fileIn, $fileOut, $width, $height, $quality = 75, $cropLeft = null, $cropTop = null, $cropWidth = null,  $cropHeight = null) 
    101101  { 
     102    $args = func_get_args(); 
     103    error_log(implode(',', $args)); 
    102104    // Allow skipping of parameters 
    103105    if (is_null($quality)) 
     
    108110    $height = ceil($height); 
    109111    $quality = ceil($quality); 
    110     list($iwidth, $iheight) = getimagesize($fileIn);  
    111     if (!$iwidth)  
     112    // Make sure we use a method that understands about JPEG orientation 
     113    $info = aImageConverter::getInfo($fileIn);  
     114    if (!$info) 
    112115    { 
    113116      return false; 
    114117    } 
     118    $iwidth = $info['width']; 
     119    $iheight = $info['height']; 
     120     
    115121    $iratio = $iwidth / $iheight; 
    116122    $ratio = $width / $height; 
     
    146152    $scale = array('xysize' => array($width + 0, $height + 0)); 
    147153    $crop = array('left' => $cropLeft, 'top' => $cropTop, 'width' => $cropWidth, 'height' => $cropHeight); 
     154    error_log("scale: " . json_encode($scale)); 
     155    error_log("crop: " . json_encode($crop)); 
    148156    return self::scaleBody($fileIn, $fileOut, $scale, $crop, $quality); 
    149157  }