-
-
Notifications
You must be signed in to change notification settings - Fork 766
Expand file tree
/
Copy pathWebPResult.php
More file actions
37 lines (29 loc) · 793 Bytes
/
WebPResult.php
File metadata and controls
37 lines (29 loc) · 793 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
declare(strict_types=1);
namespace Endroid\QrCode\Writer\Result;
use Endroid\QrCode\Matrix\MatrixInterface;
final class WebPResult extends GdResult
{
public function __construct(
MatrixInterface $matrix,
\GdImage $image,
private readonly int $quality = -1,
) {
parent::__construct($matrix, $image);
}
#[\Override]
public function getString(): string
{
if (!function_exists('imagewebp')) {
throw new \Exception('WebP support is not available in your GD installation');
}
ob_start();
imagewebp($this->image, quality: $this->quality);
return strval(ob_get_clean());
}
#[\Override]
public function getMimeType(): string
{
return 'image/webp';
}
}