Вход Регистрация
Файл: vendor/intervention/image/src/Modifiers/CropModifier.php
Строк: 61
<?php

declare(strict_types=1);

namespace 
InterventionImageModifiers;

use 
InterventionImageDriversSpecializableModifier;
use 
InterventionImageExceptionsRuntimeException;
use 
InterventionImageGeometryRectangle;
use 
InterventionImageInterfacesImageInterface;
use 
InterventionImageInterfacesSizeInterface;

class 
CropModifier extends SpecializableModifier
{
    
/**
     * Create new modifier object
     *
     * @param int $width
     * @param int $height
     * @param int $offset_x
     * @param int $offset_y
     * @param mixed $background
     * @param string $position
     * @return void
     */
    
public function __construct(
        public 
int $width,
        public 
int $height,
        public 
int $offset_x 0,
        public 
int $offset_y 0,
        public 
mixed $background 'ffffff',
        public 
string $position 'top-left'
    
) {
    }

    
/**
     * @throws RuntimeException
     */
    
public function crop(ImageInterface $image): SizeInterface
    
{
        
$crop = new Rectangle($this->width$this->height);
        
$crop->align($this->position);

        return 
$crop->alignPivotTo(
            
$image->size(),
            
$this->position
        
);
    }
}
Онлайн: 0
Реклама