Merge pull request #12341 from annando/fix-small-preview

The BlurHash function must not change the original image
pull/12347/head
Philipp 2022-12-05 21:45:37 +01:00 zatwierdzone przez GitHub
commit 8543174bf1
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
1 zmienionych plików z 11 dodań i 9 usunięć

Wyświetl plik

@ -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']];
}
}