Файл: vendor/intervention/image/src/Drivers/Gd/Encoders/WebpEncoder.php
Строк: 67
<?php
declare(strict_types=1);
namespace InterventionImageDriversGdEncoders;
use InterventionImageEncodersWebpEncoder as GenericWebpEncoder;
use InterventionImageExceptionsStreamException;
use InterventionImageExceptionsInvalidArgumentException;
use InterventionImageInterfacesEncodedImageInterface;
use InterventionImageInterfacesImageInterface;
use InterventionImageInterfacesSpecializedInterface;
class WebpEncoder extends GenericWebpEncoder implements SpecializedInterface
{
/**
* {@inheritdoc}
*
* @see EncoderInterface::encode()
*
* @throws InvalidArgumentException
* @throws StreamException
*/
public function encode(ImageInterface $image): EncodedImageInterface
{
$quality = $this->quality === 100 && defined('IMG_WEBP_LOSSLESS') ? IMG_WEBP_LOSSLESS : $this->quality;
return $this->createEncodedImage(function ($stream) use ($image, $quality): void {
imagewebp($image->core()->native(), $stream, $quality);
}, 'image/webp');
}
}