Skip to content

Commit

Permalink
Zlepšení kompatibility s PHP 8.x.
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelPavlista committed Sep 13, 2023
1 parent fb28180 commit 9509ee8
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/Effect/Resize.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ public function __construct($width, $height = NULL, $resizeMode = NULL, $resizeS
$height = $width;
}

$this->width = $width;
$this->height = $height;
$this->width = (int) $width;
$this->height = (int) $height;
$this->resizeMode = $resizeMode;
$this->resizeSmaller = $resizeSmaller ? 1 : 0;
$this->color = $color;
Expand Down Expand Up @@ -164,7 +164,11 @@ private function resizeImagick(Imagick $imagick, Picture $picture)
$height = max($imagick->getImageHeight() * $ratioH, $imagick->getImageHeight() * $ratioW);
$ratio = max($width / $imagick->getImageWidth(), $height / $imagick->getImageHeight());

$imagick->scaleImage(round($imagick->getImageWidth() * $ratio), round($imagick->getImageHeight() * $ratio), TRUE);
$imagick->scaleImage(
(int) round($imagick->getImageWidth() * $ratio),
(int) round($imagick->getImageHeight() * $ratio),
TRUE
);
}
elseif($this->resizeMode === $this::MODE_STRETCH)
{
Expand All @@ -178,9 +182,8 @@ private function resizeImagick(Imagick $imagick, Picture $picture)
$rectangle->setFormat('png');
$rectangle->newImage($this->width, $this->height, new \ImagickPixel($this->color ?: 'transparent'));
$rectangle->compositeImage($imagick, $imagick->getImageCompose(),

($rectangle->getImageWidth() - $imagick->getImageWidth()) / 2,
($rectangle->getImageHeight() - $imagick->getImageHeight()) / 2
(int) floor(($rectangle->getImageWidth() - $imagick->getImageWidth()) / 2),
(int) floor(($rectangle->getImageHeight() - $imagick->getImageHeight()) / 2)
);

$picture->setResource($rectangle);
Expand Down

0 comments on commit 9509ee8

Please sign in to comment.