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

declare(strict_types=1);

namespace 
InterventionImageDriversImagickModifiers;

use 
Imagick;
use 
ImagickException;
use 
InterventionImageExceptionsInvalidArgumentException;
use 
InterventionImageExceptionsModifierException;
use 
InterventionImageInterfacesImageInterface;
use 
InterventionImageInterfacesSpecializedInterface;
use 
InterventionImageModifiersRemoveAnimationModifier as GenericRemoveAnimationModifier;

class 
RemoveAnimationModifier extends GenericRemoveAnimationModifier implements SpecializedInterface
{
    
/**
     * @throws InvalidArgumentException
     * @throws ModifierException
     */
    
public function apply(ImageInterface $image): ImageInterface
    
{
        try {
            
// create new imagick with just one image
            
$imagick = new Imagick();
            
$frame $this->selectedFrame($image);

            
$result $imagick->addImage($frame->native()->getImage());
            if (
$result === false) {
                throw new 
ModifierException(
                    
'Failed to apply ' self::class . ', unable to re-apply image frame',
                );
            }
        } catch (
ImagickException $e) {
            throw new 
ModifierException(
                
'Failed to apply ' self::class . ', unable to re-apply image frame',
                
previous$e,
            );
        }

        
// set new imagick to image
        
$image->core()->setNative($imagick);

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