Ignore:
Timestamp:
Feb 5, 2012, 3:58:14 PM (12 years ago)
Author:
rvelices
Message:

multisize

  • watermarks loaded also from local dir
  • fix/simplify algo for cropping
  • imagick use scaleImage (fast) before resizeImage (slow) if the original is a lot bigger than the requested size
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/derivative_params.inc.php

    r13021 r13035  
    7171  }
    7272
    73   function crop_h($pixels, $coi, $force)
     73  function crop_h($pixels, $coi)
    7474  {
    7575    if ($this->width() <= $pixels)
     
    8383      $availableL = $coil > $this->l ? $coil - $this->l : 0;
    8484      $availableR = $coir < $this->r ? $this->r - $coir : 0;
    85       if ($availableL + $availableR <= $pixels)
    86       {
    87         if (!$force)
    88         {
    89           $pixels = $availableL + $availableR;
    90           $tlcrop = $availableL;
    91         }
    92       }
    93       else
     85      if ($availableL + $availableR >= $pixels)
    9486      {
    9587        if ($availableL < $tlcrop)
     
    10799  }
    108100
    109   function crop_v($pixels, $coi, $force)
     101  function crop_v($pixels, $coi)
    110102  {
    111103    if ($this->height() <= $pixels)
     
    119111      $availableT = $coit > $this->t ? $coit - $this->t : 0;
    120112      $availableB = $coib < $this->b ? $this->b - $coib : 0;
    121       if ($availableT + $availableB <= $pixels)
    122       {
    123         if (!$force)
    124         {
    125           $pixels = $availableT + $availableB;
    126           $tlcrop = $availableT;
    127         }
    128       }
    129       else
     113      if ($availableT + $availableB >= $pixels)
    130114      {
    131115        if ($availableT < $tlcrop)
     
    199183          if ($h < $this->min_size[1])
    200184          {
    201             $idealCropPx = $destCrop->width() - round($destCrop->height() * $this->ideal_size[0] / $this->min_size[1], 0);
     185            $idealCropPx = $destCrop->width() - floor($destCrop->height() * $this->ideal_size[0] / $this->min_size[1]);
    202186            $maxCropPx = round($this->max_crop * $destCrop->width());
    203             $destCrop->crop_h( min($idealCropPx, $maxCropPx), $coi, false);
     187            $destCrop->crop_h( min($idealCropPx, $maxCropPx), $coi);
    204188          }
    205189        }
     
    209193          if ($w < $this->min_size[0])
    210194          {
    211             $idealCropPx = $destCrop->height() - round($destCrop->width() * $this->ideal_size[1] / $this->min_size[0], 0);
     195            $idealCropPx = $destCrop->height() - floor($destCrop->width() * $this->ideal_size[1] / $this->min_size[0]);
    212196            $maxCropPx = round($this->max_crop * $destCrop->height());
    213             $destCrop->crop_v( min($idealCropPx, $maxCropPx), $coi, false);
     197            $destCrop->crop_v( min($idealCropPx, $maxCropPx), $coi);
    214198          }
    215199        }
     
    268252      return array('last_mod_time', 'sizing', 'sharpen', 'quality');
    269253  }
    270    
     254
    271255  function add_url_tokens(&$tokens)
    272256  {
     
    289273    return $this->sizing->ideal_size[1];
    290274  }
    291  
     275
    292276  function is_identity($in_size)
    293277  {
Note: See TracChangeset for help on using the changeset viewer.