How can I find the colour of a pixel of an image?
Answers were Sorted based on User's Feedback
Answer / laxmikant
<?php
$im = imagecreatefrompng("php.png");
$rgb = imagecolorat($im, 10, 15);
$r = ($rgb >> 16) & 0xFF;
$g = ($rgb >> 8) & 0xFF;
$b = $rgb & 0xFF;
var_dump($r, $g, $b);
?>
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / jude jeevanraj.p
This is easily done through using the imagecolorat function.
You must pass as parameters the image resource, and the x
and y co-ordinates you want to find the color of, for
instance:
$rgb = imagecolorat($im, 5, 10);
Will get a reference to the colour used at 5,10 (X,Y) on
the image.
Depending on the version of the GD library you are using
and the type of image, you may experience different return
values
| Is This Answer Correct ? | 0 Yes | 0 No |
Is it necessary to use closing tag in php?sometime without closing tag things work.why?
What is a stored procedure in mysql?
What is the meaning of "enctype= multipart/form-data" ?
How to remove the new line character from the end of a text line in php?
how to open & closing opening period in fico
How do you identify independent and dependent variables in research?
What is .htaccessfile and use of this file
How can I display text with a php script?
What is difference between include and include_once in php?
What is magic quotes?
How data or variable can be receive or send from PHP to HTML page??
Which php global variable is used for uploading a file?