我想从使用imagecolorat()的每个像素获取rgb颜色信息,而且我不确定我的语法是否将rgb值保存到$ xy中() 是正确的。我正在查看文档,但我仍然不明白发生了什么问题。使用php-gd循环从图像中获取每个像素的imagecolorat()数据
我的错误显示:解析错误:语法错误,意想不到的 '' 在/sites/uploadresults.php在线69
#loop to populate rgb values and save to array: $xy
$imagew = imagesx($img);
$imageh = imagesy($img);
$xy = array(i);
echo "Image (w,h): ($imagew, $imageh)<br/>";
$x = 0;
$y = 0;
for ($x = 0; $x <= $imagew; $x++) {
for ($y = 0;$y <= $imageh; $y++) {
$rgb = imagecolorat($img, $x, $y);
$r = ($rgb >> 16) & 0xFF;
$g = ($rgb >> 8) & 0xFF;
$b = $rgb & 0xFF;
#loop to save ($r,$g,$b) into $xy
for ($i = 0; $i <= $xytotal; $i++) {
$xy[i] = ($r, $g, $b);
}
echo "xy: $xy x: $x, y: $y <br/>";
var_dump($r, $g, $b);
}
}
整个代码是在这里:提前 http://pastebin.com/ZNDEzXFK
谢谢!
嗨理查......我是今年在FunnyGarbage的技术实习生,致力于改善您的Rich Mosaic项目! – LonelyWebCrawler