Alright guys, I've tried a lot of things and ended up ****ing up my whole program some how. Here's what I'm trying to do: I'm trying to make a barcode reader in PHP. Now, here is my WORKING code thus far:
<?php
function getpixels($pic){
//Create a new image inside of the program to examine
$image = imagecreatefrompng($pic);
//get dimensions of said image
list($width, $height) = getimagesize($pic);
//Divides the height by 2 so that we're taking a 1 pixel slice from the MIDDLE
$height = $height/2;
$width = $width-2;
//Creats an array called vars to store the digits representing the colors across
$vars = array();
//Loops the program until it gets all the way to the end of the image
for ($i=10; $i<=$width; $i++){
//Get's the color of the current position
$color = imagecolorat($image, $i, $height);
//uses array push to force the color of the current position to the end of the array
array_push($vars, $color);
}
//Makes the function return the array
return $vars;
}
$pixls = getpixels("barcode.png");
foreach($pixls as $pixl){
echo $pixl;
}
?>
It get's the pixels across, removing a 10 pixel border, and records a white space as 0 and a black as 1. Now, what I need to do is this (and have failed miserably): I need to first remove the 2 left guard bars (represented by 2 ones seperated by a 0, may be multiple ones and multiple zeros representing thicker guard bars) then compare the first set of 7 digits to this chart:
Digit Pattern Digit Pattern
0 0001101 5 0110001
1 0011001 6 0101111
2 0010011 7 0111011
3 0111101 8 0110111
4 0100011 9 0001011
Then the 2nd set of 7 etc., being sure to exclude the center guard bar, and convert each pod of 7 digits to a number above until I hit the right guard bar. How would I go about doing this?