In javascript there is function getImageData(), is there any function in PHP similar to that.
+3
A:
Have a look at the GD library functions:
http://www.php.net/manual/en/ref.image.php
EDIT:
Specifically, the getimagesize function for dimensions and more :)
EDIT
Hello again. This should help. You can get the RGB values of your image like so:
// the file
$file = 'test.gif';
// get the width and height of the image
list($width, $height) = getimagesize($file);
// create your image resource
$image = imagecreatefromgif($file);
// you could use the image width and height values here to
// iterate through each pixel using two nested for loops...
// or... set specific values for $x and $y
$x = 0;
$y = 0;
// get the colour index for the current pixel
$colourIndex = imagecolorat($image, $x, $y);
// get an array of human-readable RGB values
$colourValues = imagecolorsforindex($image, $colourIndex
// display RGB values
print_r($colourValues);
Darragh
2010-08-18 08:27:39
I search in that but can't find any function similar to that.
2010-08-18 09:02:14
okay. what do you want to do exactly? I see that getImageData() returns a CanvasPixelArray object. are you trying to extract colour values? Have a look at functions like http://www.php.net/manual/en/function.imagecolorat.php
Darragh
2010-08-18 09:36:35
yes i want to extract color values. but don't know how to do it. Please help
2010-08-18 12:42:02
okay. I've updated my answer.
Darragh
2010-08-19 00:29:08
Thank you for the solution
2010-08-20 11:59:05
+1
A:
GD is your best bet:
http://uk2.php.net/manual/en/function.imagecreatefromjpeg.php
You'll need to know the type (png, jpg) before you start.
fredley
2010-08-18 08:28:37