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

declare(strict_types=1);

namespace 
InterventionImageDriversImagickAnalyzers;

use 
ImagickException;
use 
InterventionImageAnalyzersPixelColorAnalyzer as GenericPixelColorAnalyzer;
use 
InterventionImageExceptionsAnalyzerException;
use 
InterventionImageExceptionsInvalidArgumentException;
use 
InterventionImageExceptionsStateException;
use 
InterventionImageInterfacesColorInterface;
use 
InterventionImageInterfacesColorProcessorInterface;
use 
InterventionImageInterfacesFrameInterface;
use 
InterventionImageInterfacesImageInterface;
use 
InterventionImageInterfacesSpecializedInterface;

class 
PixelColorAnalyzer extends GenericPixelColorAnalyzer implements SpecializedInterface
{
    
/**
     * @throws InvalidArgumentException
     * @throws AnalyzerException
     * @throws StateException
     */
    
public function analyze(ImageInterface $image): mixed
    
{
        if (
$this->$image->width() - || $this->$image->height() - 1) {
            throw new 
InvalidArgumentException(
                
'The specified position (' $this->', ' $this->') is not within the image area',
            );
        }

        
$colorProcessor $this->driver()->colorProcessor($image);

        return 
$this->colorAt($colorProcessor$image->core()->frame($this->frame));
    }

    
/**
     * @throws AnalyzerException
     */
    
protected function colorAt(ColorProcessorInterface $processorFrameInterface $frame): ColorInterface
    
{
        try {
            return 
$processor->import(
                
$frame->native()->getImagePixelColor($this->x$this->y),
            );
        } catch (
ImagickException $e) {
            throw new 
AnalyzerException(
                
'Failed to read pixel color at position ' $this->', ' $this->y,
                
previous$e,
            );
        }
    }
}
Онлайн: 1
Реклама