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

declare(strict_types=1);

namespace 
InterventionImageDriversImagickModifiers;

use 
ImagickException;
use 
InterventionImageExceptionsModifierException;
use 
InterventionImageExceptionsNotSupportedException;
use 
InterventionImageInterfacesImageInterface;
use 
InterventionImageInterfacesSpecializedInterface;
use 
InterventionImageModifiersTrimModifier as GenericTrimModifier;

class 
TrimModifier extends GenericTrimModifier implements SpecializedInterface
{
    
/**
     * @throws NotSupportedException
     * @throws ModifierException
     */
    
public function apply(ImageInterface $image): ImageInterface
    
{
        if (
$image->isAnimated()) {
            throw new 
NotSupportedException('Trim modifier cannot be applied to animated images');
        }

        
$imagick $image->core()->native();

        try {
            
$result $imagick->trimImage(($this->tolerance 100 $imagick->getQuantum()) / 1.5)
                && 
$imagick->setImagePage(0000);

            if (
$result === false) {
                throw new 
ModifierException(
                    
'Failed to apply ' self::class . ', unable to processs image trimming',
                );
            }
        } catch (
ImagickException $e) {
            throw new 
ModifierException(
                
'Failed to apply ' self::class . ', unable to processs image trimming',
                
previous$e,
            );
        }

        return 
$image;
    }
}
Онлайн: 2
Реклама