@SidorKovpak

Resize webp php7.2 выдает черный экран. Что не так?

Добрый вечер, уважаемое сообщество!
При переносе проекта с dev среды (openserver 5.2.2, php7.2, apache) на продакт сервер, возникла проблема с обработкой изображений.
Что делаю:
1) Принимаю jpg
2) Конвертирую его в webp с помощью imagewebp (отличное изображение)
3) Изменяю размер webp файла до 800х200px
4) Сохраняю измененный файл (поначалу 1/3 изображения в ужасном качестве, а через секунд 10 черный экран, хотя файл с правильным размером ~ 50кб)

Использую в проекте gumlet/php-image-resize библиотеку. В ней заметил вот такие строки при сохранении:
public function save($filename, $image_type = null, $quality = null, $permissions = null)
    {
        $image_type = $image_type ?: $this->source_type;
        $quality = is_numeric($quality) ? (int) abs($quality) : null;

        switch ($image_type) {
            case IMAGETYPE_GIF:
                $dest_image = imagecreatetruecolor($this->getDestWidth(), $this->getDestHeight());

                $background = imagecolorallocatealpha($dest_image, 255, 255, 255, 1);
                imagecolortransparent($dest_image, $background);
                imagefill($dest_image, 0, 0, $background);
                imagesavealpha($dest_image, true);
                break;

            case IMAGETYPE_JPEG:
                $dest_image = imagecreatetruecolor($this->getDestWidth(), $this->getDestHeight());

                $background = imagecolorallocate($dest_image, 255, 255, 255);
                imagefilledrectangle($dest_image, 0, 0, $this->getDestWidth(), $this->getDestHeight(), $background);
                break;

            case IMAGETYPE_WEBP:
                if (version_compare(PHP_VERSION, '5.5.0', '<')) {
                    throw new ImageResizeException('For WebP support PHP >= 5.5.0 is required');
                }
                $dest_image = imagecreatetruecolor($this->getDestWidth(), $this->getDestHeight());

                $background = imagecolorallocate($dest_image, 255, 255, 255);
                imagefilledrectangle($dest_image, 0, 0, $this->getDestWidth(), $this->getDestHeight(), $background);
                break;

            case IMAGETYPE_PNG:
                if (!$this->quality_truecolor && !imageistruecolor($this->source_image)) {
                    $dest_image = imagecreate($this->getDestWidth(), $this->getDestHeight());

                    $background = imagecolorallocatealpha($dest_image, 255, 255, 255, 1);
                    imagecolortransparent($dest_image, $background);
                    imagefill($dest_image, 0, 0, $background);
                } else {
                    $dest_image = imagecreatetruecolor($this->getDestWidth(), $this->getDestHeight());
                }

                imagealphablending($dest_image, false);
                imagesavealpha($dest_image, true);
                break;
        }

        imageinterlace($dest_image, $this->interlace);

        imagecopyresampled(
            $dest_image,
            $this->source_image,
            $this->dest_x,
            $this->dest_y,
            $this->source_x,
            $this->source_y,
            $this->getDestWidth(),
            $this->getDestHeight(),
            $this->source_w,
            $this->source_h
        );


        $this->applyFilter($dest_image);

        switch ($image_type) {
            case IMAGETYPE_GIF:
                imagegif($dest_image, $filename);
                break;

            case IMAGETYPE_JPEG:
                if ($quality === null || $quality > 100) {
                    $quality = $this->quality_jpg;
                }

                imagejpeg($dest_image, $filename, $quality);
                break;

            case IMAGETYPE_WEBP:
                if (version_compare(PHP_VERSION, '5.5.0', '<')) {
                    throw new ImageResizeException('For WebP support PHP >= 5.5.0 is required');
                }
                if ($quality === null) {
                    $quality = $this->quality_webp;
                }

                imagewebp($dest_image, $filename, $quality);
                break;

            case IMAGETYPE_PNG:
                if ($quality === null || $quality > 9) {
                    $quality = $this->quality_png;
                }

                imagepng($dest_image, $filename, $quality);
                break;
        }

        if ($permissions) {
            chmod($filename, $permissions);
        }

        imagedestroy($dest_image);

        return $this;
    }

(Удалил код для jpg, png и gif) На jpg и png работает все нормально.
На рабочей станции установлен nginx+php-fpm (php 7.2). GD установил, включил. Установил библиотеку webp. Подскажите где может быть ошибка?
  • Вопрос задан
  • 484 просмотра
Пригласить эксперта
Ответы на вопрос 1
SilenceOfWinter
@SilenceOfWinter Куратор тега PHP
та еще зажигалка...
imagealphablending: для true color изображений blendmode = true
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы
11 мая 2024, в 00:19
1000 руб./за проект
10 мая 2024, в 23:51
30000 руб./за проект
10 мая 2024, в 23:33
2500 руб./за проект