mirror of
https://github.com/friendica/friendica
synced 2024-11-09 23:02:54 +00:00
round scaled dimensions up to avoid zero size
This commit is contained in:
parent
e9dcf15d86
commit
c5b8abcaf0
2 changed files with 8 additions and 5 deletions
|
@ -591,6 +591,9 @@ class Image
|
||||||
if (!$this->isValid()) {
|
if (!$this->isValid()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if ($dest_width <= 0 || $dest_height <= 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->isImagick()) {
|
if ($this->isImagick()) {
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -418,19 +418,19 @@ class Images
|
||||||
|
|
||||||
if ((($height * 9) / 16) > $width) {
|
if ((($height * 9) / 16) > $width) {
|
||||||
$dest_width = $max;
|
$dest_width = $max;
|
||||||
$dest_height = intval(($height * $max) / $width);
|
$dest_height = intval(ceil(($height * $max) / $width));
|
||||||
} elseif ($width > $height) {
|
} elseif ($width > $height) {
|
||||||
// else constrain both dimensions
|
// else constrain both dimensions
|
||||||
$dest_width = $max;
|
$dest_width = $max;
|
||||||
$dest_height = intval(($height * $max) / $width);
|
$dest_height = intval(ceil(($height * $max) / $width));
|
||||||
} else {
|
} else {
|
||||||
$dest_width = intval(($width * $max) / $height);
|
$dest_width = intval(ceil(($width * $max) / $height));
|
||||||
$dest_height = $max;
|
$dest_height = $max;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ($width > $max) {
|
if ($width > $max) {
|
||||||
$dest_width = $max;
|
$dest_width = $max;
|
||||||
$dest_height = intval(($height * $max) / $width);
|
$dest_height = intval(ceil(($height * $max) / $width));
|
||||||
} else {
|
} else {
|
||||||
if ($height > $max) {
|
if ($height > $max) {
|
||||||
// very tall image (greater than 16:9)
|
// very tall image (greater than 16:9)
|
||||||
|
@ -440,7 +440,7 @@ class Images
|
||||||
$dest_width = $width;
|
$dest_width = $width;
|
||||||
$dest_height = $height;
|
$dest_height = $height;
|
||||||
} else {
|
} else {
|
||||||
$dest_width = intval(($width * $max) / $height);
|
$dest_width = intval(ceil(($width * $max) / $height));
|
||||||
$dest_height = $max;
|
$dest_height = $max;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue