【发布时间】:2012-10-28 23:12:50
【问题描述】:
请帮我计算图像中的像素数,或者输出 RGB 数组。
所以这是从数组中给我一个元素的脚本:
<?php
$img = "1.png";
$imgHand = imagecreatefrompng("$img");
$imgSize = GetImageSize($img);
$imgWidth = $imgSize[0];
$imgHeight = $imgSize[1];
echo '<img src="'.$img.'"><br><br>';
for ($l = 0; $l < $imgHeight; $l++) {
for ($c = 0; $c < $imgWidth; $c++) {
$pxlCor = ImageColorAt($imgHand,$c,$l);
$pxlCorArr = ImageColorsForIndex($imgHand, $pxlCor);
}
}
print_r($pxlCorArr);
?>
对不起我的英语来自乌克兰
【问题讨论】:
-
$numOfPix = $imgWidth * $imgHeight; -
你到底想做什么?图像中的像素总数,如 imgwidth x imageheight 还是什么?
-
我相信他想要整个图像的
$pxlCorArr,其中索引是像素,值是颜色..否则他的代码没有任何意义。 -
我尝试将所有像素放入数组中,然后输出 RGB 代码
标签: php