19declare(strict_types=1);
87 $clone->quality = $image_quality;
108 if (!in_array(
$format, $this->allowed_formats,
true)) {
109 throw new \InvalidArgumentException(
'Format must be one of ' . implode(
', ', $this->allowed_formats) .
', but ' .
$format .
' was given.');
116 if ($this->format === self::FORMAT_WEBP) {
117 if ($image_quality !== 0 && $image_quality !== 100) {
118 throw new \InvalidArgumentException(
'WebP only supports quality 0 (loss) or 100 (losless)');
120 } elseif ($image_quality < 0 || $image_quality > 100) {
121 throw new \InvalidArgumentException(
'Quality must be between 0 and 100');
withFormat(string $format)
@description set the desired output format.
withPngOutput()
@description set the output format to PNG
checkImageQuality(int $image_quality)
withWebPOutput()
@description set the output format to WEBP
withJpgOutput()
@description set the output format to JPG
withQuality(int $image_quality)
@description set the image compression quality.
checkFormat(string $format)