jake2891 Posted December 2, 2008 Share Posted December 2, 2008 Hey guys im tring to write a script for a challenge and im a little stuck. I need to read the pixels of an image and if the pixel is white get its position. Below is my code i think the problem is in my $chk part any ideas? list($width, $height) = getimagesize('./test.png'); $image = imagecreatefrompng('./test.png'); $ascii = array(); $i = 0; for($row=0;$row<$height;$row++){ for($column=0;$column<$width;$column++){ $pos = imagecolorat($image,$row,$column); $chk = ($pos & 0xFFFFFF); if($chk){ $ascii[] = $i; $i = 0; }else{ $i++; } } } $convert = array(); foreach($ascii as $asc){ $convert[] = chr($asc); } print_r($convert); Link to comment https://forums.phpfreaks.com/topic/135137-php-image-pixel-manipulation/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.