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

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

Echo is used to Display message on screen. Which is used with echo to not output the trailing newline?

569


Tell me what is needed to be able to use image function?

538


How to check curl is enabled or not in PHP

625


What is magic quotes?

599


Does php have a future?

509






Tell us how can we access the data sent through the url with the post method?

517


Can we extend final class in php?

507


Does php 7 support mysql?

558


Explain the difference between isset() and empty()?

530


Explain what is the use of "echo" in php?

552


What is string in php?

556


How to convert strings in hex format?

558


How to replace a substring in a given string?

547


Explain the value of the variable input is a string 1,2,3,4,5,6,7. How would you get the sum of the integers contained inside input?

567


Explain scalar type declarations in php7?

551