Файл: vendor/intervention/image/src/Drivers/Gd/Modifiers/FillTransparentAreasModifier.php
Строк: 96
<?php
declare(strict_types=1);
namespace InterventionImageDriversGdModifiers;
use InterventionImageColorsRgbColorspace as RgbColorspace;
use InterventionImageDriversGdCloner;
use InterventionImageInterfacesImageInterface;
use InterventionImageInterfacesSpecializedInterface;
use InterventionImageModifiersFillTransparentAreasModifier as GenericFillTransparentAreasModifier;
use InterventionImageColorsRgbColor as RgbColor;
use InterventionImageExceptionsDriverException;
use InterventionImageExceptionsInvalidArgumentException;
use InterventionImageExceptionsModifierException;
use InterventionImageExceptionsStateException;
class FillTransparentAreasModifier extends GenericFillTransparentAreasModifier implements SpecializedInterface
{
/**
* {@inheritdoc}
*
* @see ModifierInterface::apply()
*
* @throws InvalidArgumentException
* @throws ModifierException
* @throws StateException
* @throws DriverException
*/
public function apply(ImageInterface $image): ImageInterface
{
$backgroundColor = $this->backgroundColor($this->driver())->toColorspace(RgbColorspace::class);
if (!$backgroundColor instanceof RgbColor) {
throw new ModifierException('Failed to normalize background color to RGB color space');
}
foreach ($image as $frame) {
// create new canvas with background color as background
$modified = Cloner::cloneBlended(
$frame->native(),
background: $backgroundColor,
);
// set new gd image
$frame->setNative($modified);
}
return $image;
}
}