How can I find the colour of a pixel of an image?

Answers were Sorted based on User's Feedback



How can I find the colour of a pixel of an image? ..

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

How can I find the colour of a pixel of an image? ..

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

Post New Answer

More PHP Interview Questions

What are form input html tags?

0 Answers  


What is polymorphism?

0 Answers  


How to access standard error stream in PHP?

0 Answers  


How to get a random value from a php array?

0 Answers  


What is delimiter php?

0 Answers  






if you run the app program all vendor open items are cleared but is it possible to reverse the again again open items please tell me the answer

0 Answers   Yash Technologies,


Write a function that takes "depth" as argument and return sum of node's data of that depth. For instance, (0) depth 0 / \ (10) (20) depth 1 / \ (40) (50) depth2 If I pass get_sum_by_depth(2) , it would return 90 (i.e. 40 + 50 )

0 Answers   Amazon,


What and How possible injection in PHP and mysql?

3 Answers   RedAlkemi,


What is an example of a variable?

0 Answers  


What is php key?

0 Answers  


How do I find out the number of parameters passed into function?

1 Answers  


can any one tell how to install LAMP server in terminal in ubuntu.....and also tell please how to run php files in ubunut and how to save and compile in ubuntu..i already installed ubuntu ..but i dont installed lamp server so i want to install lamp server in terminal is it possible please reply

2 Answers  


Categories