diff --git a/app/Jobs/OptimizeStickerJob.php b/app/Jobs/OptimizeStickerJob.php index fa64534..8c426eb 100644 --- a/app/Jobs/OptimizeStickerJob.php +++ b/app/Jobs/OptimizeStickerJob.php @@ -64,14 +64,19 @@ public function handle(Nutgram $bot): void $image->filter(WatermarkFilter::make($chatSettings)); //compress image - $quality = 100; - do { - $stream = $image->stream('png', $quality); - $quality--; - } while ($stream->getSize() > TelegramLimit::STICKER_MAX_SIZE); + $ext = 'png'; + $stream = $image->stream('png'); + if ($stream->getSize() > TelegramLimit::STICKER_MAX_SIZE) { + $quality = 100; + do { + $stream = $image->stream('webp', $quality); + $quality--; + } while ($stream->getSize() > TelegramLimit::STICKER_MAX_SIZE); + $ext = 'webp'; + } //send optimized image - $bot->sendDocument(InputFile::make($stream->detach(), Str::uuid().'.png'), [ + $bot->sendDocument(InputFile::make($stream->detach(), Str::uuid().'.'.$ext), [ 'caption' => message('donate.caption'), 'parse_mode' => ParseMode::HTML, 'chat_id' => $this->chatID,