From: Michael Date: Mon, 5 Dec 2022 20:38:21 +0000 (+0000) Subject: The BlurHash function must not change the original image X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=a260e97b6fd0ec73af1189ca80fef9f6bb1499be;p=friendica.git The BlurHash function must not change the original image --- diff --git a/src/Object/Image.php b/src/Object/Image.php index 6eb8620031..c798f250ed 100644 --- a/src/Object/Image.php +++ b/src/Object/Image.php @@ -733,25 +733,27 @@ class Image */ public function getBlurHash(): string { - $width = $this->getWidth(); - $height = $this->getHeight(); + $image = New Image($this->asString()); + + $width = $image->getWidth(); + $height = $image->getHeight(); if (max($width, $height) > 90) { - $this->scaleDown(90); - $width = $this->getWidth(); - $height = $this->getHeight(); + $image->scaleDown(90); + $width = $image->getWidth(); + $height = $image->getHeight(); } $pixels = []; for ($y = 0; $y < $height; ++$y) { $row = []; for ($x = 0; $x < $width; ++$x) { - if ($this->isImagick()) { - $colors = $this->image->getImagePixelColor($x, $y)->getColor(); + if ($image->isImagick()) { + $colors = $image->image->getImagePixelColor($x, $y)->getColor(); $row[] = [$colors['r'], $colors['g'], $colors['b']]; } else { - $index = imagecolorat($this->image, $x, $y); - $colors = @imagecolorsforindex($this->image, $index); + $index = imagecolorat($image->image, $x, $y); + $colors = @imagecolorsforindex($image->image, $index); $row[] = [$colors['red'], $colors['green'], $colors['blue']]; } }