Better way to get map of all pixels of an image with GD
The following code uses the SimpleImage library I have a function that gets a pixel from an image: function getPixel($x, $y) { $colors = imagecolorsforindex($this->image, imagecolorat($this->image, $x, $y)); $n[0] = $colors['red']; $n[1] = $colors['green']; $n[2] = $colors['blue']; $str = "#"; for($x=0;$x < 3; $x++){ $n[$x] = intval($n[$x],10); if (is_nan($n[$x])) return "00"; $n[$x] = max(0, min($n[$x],255)); $bam = "0123456789ABCDEF"; $str .= $bam{($n[$x]-$n[$x]%16)/16} . $bam{$n[$x]%16}; } return $str; } To get every pixel in an image, I use this loop: $arr = []; for($y = 0;$y < $image-