PHP.mk документација

Imagick::getImagePixelColor

Почист и полокален преглед на PHP референцата, со задржана структура од PHP.net и подобра читливост за примери, секции и белешки.

imagick.getimagepixelcolor.php PHP.net прокси Преводот се освежува
Оригинал на PHP.net
Патека imagick.getimagepixelcolor.php Локална патека за оваа страница.
Извор php.net/manual/en Оригиналниот HTML се реупотребува и локално се стилизира.
Режим Прокси + превод во позадина Кодовите, табелите и белешките остануваат читливи во истиот тек.
Imagick::getImagePixelColor

Референца за `imagick.getimagepixelcolor.php` со подобрена типографија и навигација.

imagick.getimagepixelcolor.php

Imagick::getImagePixelColor

(PECL imagick 2, PECL imagick 3)

Imagick::getImagePixelColorReturns the color of the specified pixel

= NULL

public Imagick::getImagePixelColor(int $x, int $y): ImagickPixel

Returns the color of the specified pixel.

Параметри

x

The x-coordinate of the pixel

y

The y-coordinate of the pixel

Вратени вредности

Returns an ImagickPixel instance for the color at the coordinates given.

Errors/Exceptions

Фрла ImagickException при грешка.

Белешки од корисници 1 белешка

sheldon na hyperlinked dot com
пред 13 години
I'm sure there are a lot of people like me who have been wondering, "How you manage to produce a human readable output of this operation?"

<?php
$image = new Imagick('testimage.jpg');

$x = 1; 
$y = 1;
$pixel = $image->getImagePixelColor($x, $y);
?>

If you try to print an output of the $pixel object, you get nothing. You have to use one of the ImagickPixel operations to get back a value.

You can do either of the following:

<?php
$colors = $pixel->getColor();
print_r($colors); // produces Array([r]=>255,[g]=>255,[b]=>255,[a]=>1);

$pixel->getColorAsString(); // produces rgb(255,255,255);
?>

The place where I was getting hung up was how to get the data that was captured in the Imagick::getImagePixelColor operation into an ImagickPixel object. I was trying to find ways of passing the value to a newly instantiated ImagickPixel object. Well, it appears that once you've captured your color data using Imagick::getImagePixelColor, what's returned IS an ImagickPixel object!

As a further note, you do not need to convert this to a human readable format if you just want to take a color sample at a single point on your image to plug into another operation. 

For example, if you wanted to perform a flood fill effect on a certain color you could plug in the instance of the ImagickPixel object directly. 

The following fill perform a flood fill effect at coordinates 1,1 on your image using Green as the fill color and the color sampled at 1,1 as the target color to fill.

<?php
$hexcolor = '#00ff00';
$fuzz = '4000';
$x = 1;
$y = 1;
$pixel = $image->getImagePixelColor($x, $y);
$image->floodfillPaintImage($hexcolor, $fuzz, $pixel, $x, $y, false);
?>
Навигација

Прелистувај сродни теми и функции.

На оваа страница

Автоматски outline од активната документација.

Насловите ќе се појават тука по вчитување.

Попрегледно читање

Примерите, changelog табелите и user notes се визуелно издвоени за да не се губат во долгата содржина.

Брз совет Користи го outline-от Скокни директно на главните секции од активната страница.
Извор Оригиналниот линк останува достапен Кога ти треба целосен upstream context, отвори го PHP.net во нов tab.