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

declare(strict_types=1);

namespace 
InterventionImageDriversGdAnalyzers;

use 
GdImage;
use 
InterventionImageAnalyzersPixelColorAnalyzer as GenericPixelColorAnalyzer;
use 
InterventionImageExceptionsColorException;
use 
InterventionImageExceptionsGeometryException;
use 
InterventionImageInterfacesColorInterface;
use 
InterventionImageInterfacesColorspaceInterface;
use 
InterventionImageInterfacesImageInterface;
use 
InterventionImageInterfacesSpecializedInterface;

class 
PixelColorAnalyzer extends GenericPixelColorAnalyzer implements SpecializedInterface
{
    
/**
     * {@inheritdoc}
     *
     * @see AnalyzerInterface::analyze()
     */
    
public function analyze(ImageInterface $image): mixed
    
{
        return 
$this->colorAt(
            
$image->colorspace(),
            
$image->core()->frame($this->frame_key)->native()
        );
    }

    
/**
     * @throws GeometryException
     * @throws ColorException
     */
    
protected function colorAt(ColorspaceInterface $colorspaceGdImage $gd): ColorInterface
    
{
        
$index = @imagecolorat($gd$this->x$this->y);

        if (!
imageistruecolor($gd)) {
            
$index imagecolorsforindex($gd$index);
        }

        if (
$index === false) {
            throw new 
GeometryException(
                
'The specified position is not in the valid image area.'
            
);
        }

        return 
$this->driver()->colorProcessor($colorspace)->nativeToColor($index);
    }
}
Онлайн: 3
Реклама