Reputation: 1323
In javascript there is function getImageData(), is there any function in PHP similar to that.
Upvotes: 0
Views: 104
Reputation: 33901
GD is your best bet:
http://php.net/manual/en/function.imagecreatefromjpeg.php
You'll need to know the type (png, jpg) before you start.
Upvotes: 1
Reputation: 14136
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);
Upvotes: 3