Reputation: 2344
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?
Upvotes: 3
Views: 2740
Reputation: 1376
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
Upvotes: 10