Added ability to choose between resolution modulus
This commit is contained in:
parent
f623bb9107
commit
d7c7e74c25
1 changed files with 8 additions and 25 deletions
|
|
@ -332,9 +332,8 @@ class FFMpeg extends Binary
|
||||||
|
|
||||||
if ($originalHeight !== null && $originalWidth !== null) {
|
if ($originalHeight !== null && $originalWidth !== null) {
|
||||||
$dimensions = $format->getComputedDimensions($originalWidth, $originalHeight);
|
$dimensions = $format->getComputedDimensions($originalWidth, $originalHeight);
|
||||||
|
$width = $this->getMultiple($dimensions->getWidth(), $format->getModulus());
|
||||||
$width = $this->getMultiple($dimensions->getWidth(), 16);
|
$height = $this->getMultiple($dimensions->getHeight(), $format->getModulus());
|
||||||
$height = $this->getMultiple($dimensions->getHeight(), 16);
|
|
||||||
|
|
||||||
$builder->add('-s')->add($width . 'x' . $height);
|
$builder->add('-s')->add($width . 'x' . $height);
|
||||||
}
|
}
|
||||||
|
|
@ -455,31 +454,15 @@ class FFMpeg extends Binary
|
||||||
*/
|
*/
|
||||||
protected function getMultiple($value, $multiple)
|
protected function getMultiple($value, $multiple)
|
||||||
{
|
{
|
||||||
$modulo = $value % $multiple;
|
if (($value % $multiple) === 0){
|
||||||
|
return $value;
|
||||||
$ret = (int) $multiple;
|
|
||||||
|
|
||||||
$halfDistance = $multiple / 2;
|
|
||||||
if ($modulo <= $halfDistance)
|
|
||||||
$bound = 'bottom';
|
|
||||||
else
|
|
||||||
$bound = 'top';
|
|
||||||
|
|
||||||
switch ($bound) {
|
|
||||||
default:
|
|
||||||
case 'top':
|
|
||||||
$ret = $value + $multiple - $modulo;
|
|
||||||
break;
|
|
||||||
case 'bottom':
|
|
||||||
$ret = $value - $modulo;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($ret < $multiple) {
|
do {
|
||||||
$ret = (int) $multiple;
|
$value++;
|
||||||
}
|
} while (($value % $multiple) != 0);
|
||||||
|
|
||||||
return (int) $ret;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue