I am trying to get the first pixel of the image. preferably, the one very top left or right pixel. I saw this question and it has the closest answer to my question : Get image color
However, the answer only shows you how to get the average color. I do not want to get the average color, I want to get the first pixel from any side! anybody know of a way to do it?
Try this, it gets the color of the top-left pixel (0,0):
<?php
$im = imagecreatefrompng("image.png");
$rgb = imagecolorat($im, 0, 0);
$colors = imagecolorsforindex($im, $rgb);
var_dump($colors);
?>
More info: http://php.net/manual/en/function.imagecolorat.php
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With