aboutsummaryrefslogtreecommitdiffstats
path: root/include/derivative_params.inc.php
diff options
context:
space:
mode:
authorrvelices <rv-github@modusoptimus.com>2012-02-05 14:58:14 +0000
committerrvelices <rv-github@modusoptimus.com>2012-02-05 14:58:14 +0000
commit8d86e7b399fbda576306453c332cd9daeb44bdde (patch)
tree4288b52b6052b9aeed9704e3ed12f12426c187d8 /include/derivative_params.inc.php
parentcb36388114b6d7b35a71243c5ad23854da12fe33 (diff)
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 git-svn-id: http://piwigo.org/svn/trunk@13035 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include/derivative_params.inc.php')
-rw-r--r--include/derivative_params.inc.php36
1 files changed, 10 insertions, 26 deletions
diff --git a/include/derivative_params.inc.php b/include/derivative_params.inc.php
index ba1b1dce7..15c78c9aa 100644
--- a/include/derivative_params.inc.php
+++ b/include/derivative_params.inc.php
@@ -70,7 +70,7 @@ final class ImageRect
return $this->b - $this->t;
}
- function crop_h($pixels, $coi, $force)
+ function crop_h($pixels, $coi)
{
if ($this->width() <= $pixels)
return;
@@ -82,15 +82,7 @@ final class ImageRect
$coir = ceil($this->r * char_to_fraction($coi[2]));
$availableL = $coil > $this->l ? $coil - $this->l : 0;
$availableR = $coir < $this->r ? $this->r - $coir : 0;
- if ($availableL + $availableR <= $pixels)
- {
- if (!$force)
- {
- $pixels = $availableL + $availableR;
- $tlcrop = $availableL;
- }
- }
- else
+ if ($availableL + $availableR >= $pixels)
{
if ($availableL < $tlcrop)
{
@@ -106,7 +98,7 @@ final class ImageRect
$this->r -= $pixels - $tlcrop;
}
- function crop_v($pixels, $coi, $force)
+ function crop_v($pixels, $coi)
{
if ($this->height() <= $pixels)
return;
@@ -118,15 +110,7 @@ final class ImageRect
$coib = ceil($this->b * char_to_fraction($coi[3]));
$availableT = $coit > $this->t ? $coit - $this->t : 0;
$availableB = $coib < $this->b ? $this->b - $coib : 0;
- if ($availableT + $availableB <= $pixels)
- {
- if (!$force)
- {
- $pixels = $availableT + $availableB;
- $tlcrop = $availableT;
- }
- }
- else
+ if ($availableT + $availableB >= $pixels)
{
if ($availableT < $tlcrop)
{
@@ -198,9 +182,9 @@ final class SizingParams
$h = $destCrop->height() / $ratio_w;
if ($h < $this->min_size[1])
{
- $idealCropPx = $destCrop->width() - round($destCrop->height() * $this->ideal_size[0] / $this->min_size[1], 0);
+ $idealCropPx = $destCrop->width() - floor($destCrop->height() * $this->ideal_size[0] / $this->min_size[1]);
$maxCropPx = round($this->max_crop * $destCrop->width());
- $destCrop->crop_h( min($idealCropPx, $maxCropPx), $coi, false);
+ $destCrop->crop_h( min($idealCropPx, $maxCropPx), $coi);
}
}
else
@@ -208,9 +192,9 @@ final class SizingParams
$w = $destCrop->width() / $ratio_h;
if ($w < $this->min_size[0])
{
- $idealCropPx = $destCrop->height() - round($destCrop->width() * $this->ideal_size[1] / $this->min_size[0], 0);
+ $idealCropPx = $destCrop->height() - floor($destCrop->width() * $this->ideal_size[1] / $this->min_size[0]);
$maxCropPx = round($this->max_crop * $destCrop->height());
- $destCrop->crop_v( min($idealCropPx, $maxCropPx), $coi, false);
+ $destCrop->crop_v( min($idealCropPx, $maxCropPx), $coi);
}
}
}
@@ -267,7 +251,7 @@ final class DerivativeParams
{
return array('last_mod_time', 'sizing', 'sharpen', 'quality');
}
-
+
function add_url_tokens(&$tokens)
{
$this->sizing->add_url_tokens($tokens);
@@ -288,7 +272,7 @@ final class DerivativeParams
{
return $this->sizing->ideal_size[1];
}
-
+
function is_identity($in_size)
{
if ($in_size[0] > $this->sizing->ideal_size[0] or