Image::pickColor
Pick a color out of the current image
2.9M Downloads / Month
Open Source MIT License
2.9M Downloads / Month
Open Source MIT License
public Intervention\Image\Image pickColor(int $x, int $y, [string $format])
Pick a color at point x, y out of current image and return in optional given format.
x-coordinate of the pixel the color is picked from.
y-coordinate of the pixel the color is picked from.
Select the color to be formated in one of the different types:
[255, 255, 255, 1]
rgb(255, 255, 255)
rgba(255, 255, 255, 0.5)
#cccccc
16776956
By default the method returns the RGB value of that pixel as an array. Use the integer format to pass colors directly into any GD Library functions.
mixed - Depends on format parameter. By default an array of the RGB and alpha values.
// create an image
$img = Image::make('public/foo.jpg');
// pick a color at position as array
$arraycolor = $img->pickColor(100, 100);
// pick a color at position as integer
$intcolor = $img->pickColor(100, 100, 'int');
// pick a color at position and format it as hex string
$hexcolor = $img->pickColor(100, 100, 'hex');
Edit