Файл: vendor/intervention/image/src/Modifiers/InsertModifier.php
Строк: 78
<?php
declare(strict_types=1);
namespace InterventionImageModifiers;
use InterventionImageAlignment;
use InterventionImageDriversSpecializableModifier;
use InterventionImageExceptionsInvalidArgumentException;
use InterventionImageInterfacesImageInterface;
use InterventionImageInterfacesPointInterface;
class InsertModifier extends SpecializableModifier
{
/**
* Create new modifier object.
*
* @throws InvalidArgumentException
*/
public function __construct(
public mixed $image,
public int $x = 0,
public int $y = 0,
public string|Alignment $alignment = Alignment::TOP_LEFT,
public float $transparency = 1,
) {
if ($this->transparency < 0 || $this->transparency > 1) {
throw new InvalidArgumentException('Transparency must be in range 0 to 1');
}
}
/**
* Calculate position of the watermark to be inserted on the image.
*/
public function position(ImageInterface $image, ImageInterface $watermark): PointInterface
{
$imageSize = $image->size()->movePivot(
$this->alignment,
$this->x,
$this->y,
);
$watermarkSize = $watermark->size()->movePivot(
$this->alignment,
);
return $imageSize->offsetTo($watermarkSize);
}
}