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 |
Which function(s) in PHP computes the difference of arrays?
What is the difference between characters 34 and x34?
How to open a file in php?
What is the difference between myisam and innodb?
What is the difference between array_pop() and array_push()?
What is the default time in seconds for which session data is considered valid?
What is the main difference between require() and require_once()?
Seeking a PHP skilled programmer, with knowledge of MySQL Database, Javascript and AJAX. CSS and HTML is a plus. Temporary job for 2 months. Possibility of extending the contract (depending on how good you are). Location: Delhi. Start: ASAP Contact me at boney@portlane.com together with your CV.
How many functions are there in php?
What is laracast?
What is reference variable php?
How can you submit a form without a submit button?