Page 1 of 1

barcode ?

Posted: Mon Sep 17, 2007 8:38 pm
by myharshdesigner
is there any function in php through which we can create barcode ?

or any other libraries through which we can create barcodes ?

& i also need to read barcodes so what i supposed to do ?






Thanks

Posted: Mon Sep 17, 2007 9:03 pm
by VladSun

Posted: Mon Sep 17, 2007 9:03 pm
by Zoxive
*Cough* http://www.google.com/search?q=php+barcodes

As for Reading them, your going to need well, a Reader.

Posted: Mon Sep 17, 2007 10:08 pm
by ReDucTor
If your talking about reading using a bar code reader, you dont need to anything, those will just output the bar code value for you as input, bar codes are very simple to make, well atleast Code 39 is.

http://en.wikipedia.org/wiki/Code_39

Pretty much just a matter of specifing your wide and narrow lengths for each letter, and your start/stop

Very very easy.

Posted: Mon Sep 17, 2007 11:05 pm
by myharshdesigner
Thanks For your replys.


But i want to develop my own Barcode Creator and reader . So how to do that ?

i want to develop it for website

Posted: Mon Sep 17, 2007 11:08 pm
by feyd
Then you need to read all of the specifications then develop your own graphics library to build them. Reading them via PHP without a reader, while possible, is potentially quite difficult, to say the least.

Posted: Mon Sep 17, 2007 11:18 pm
by s.dot
feyd wrote:Then you need to read all of the specifications then develop your own graphics library to build them. Reading them via PHP without a reader, while possible, is potentially quite difficult, to say the least.
How is that possible? Scanned images with GD disecting the image?

Posted: Mon Sep 17, 2007 11:21 pm
by ReDucTor
I've worked with barcodes before, both generating them and reading them. I disagree its not hard at all.

Are you working with one set format? Most people use Code-39 unless they have to stick to a standard.

As for using a graphics library, while not hard, not completely important, hell you can even build a table, with specified widths and different background colors to make the barcode, not recommended, but possible.

What data are you wanting to store in the barcode? What information do you already have stored with bar codes?

Posted: Tue Sep 18, 2007 12:29 am
by myharshdesigner
ReDucTor wrote:I've worked with barcodes before, both generating them and reading them. I disagree its not hard at all.

Are you working with one set format? Most people use Code-39 unless they have to stick to a standard.

As for using a graphics library, while not hard, not completely important, hell you can even build a table, with specified widths and different background colors to make the barcode, not recommended, but possible.

What data are you wanting to store in the barcode? What information do you already have stored with bar codes?
dear sir pl guide us how to start to develop our own Barcode reader and generator.

We are plannying to store Price in numeric and if possible the some text [ Decription of a product ].

waiting for your help.............
thanks sir

Posted: Tue Sep 18, 2007 1:10 am
by ReDucTor
I highly recommend not storing barcodes with all that information in it, you will have rather long bar codes, as a product description will need make a rather long barcode, and will be a pain in the arse to scan. Storing float point values, would be possible, how ever not very useful if your storing price, as prices may vary.

My recommendation is to store an item number, this can be done with any number of bar codes, UPC/EAN, Code 39,93,128,etc

First things first with generation of any of these is to make your tables, for is needed for each character.

Code: Select all

$code39=array( // 0 = narrow, 1 = wide
'*' => '010010100'
0=>'000110100',
1=>'100100001',
2=>'001100001',
3=>'101100000',
4=>'000110001',
5=>'100110000',
6=>'001110000',
7=>'000100101',
8=>'100100100',
9=>'001100100');

$narrow = 20;
$wide = 2*$narrow; // between 1:2 and 1:3
$height = 100;

$str = '1337';
//Add start/stop
$str = '*'.$str.'*';

echo '<table cellspacing="0" cellpadding="0" height="'.$height.'"><tr height="100%">';
// Loop chars
foreach($str as $s) {
  $code = $code39[$s];
  for($i=0;$i<strlen($code);$i++) {
    $type = $code[$i];
    echo '<td width="'.($type?$wide:$height).'" bgcolor="'.($i%2?'black':'white').'">&nbsp;</td>';
  }
}
echo '</tr></table>';
?>
Most basic example you'll get.

Now as for reading code 39 w/o reader, you simply determine the wide/narrow differences by looking at the start/stop. I dont know why you would be storing barcodes if your only going to be reading it using a scanner or something, barcode readers will interpret it for you. But we all end up doing these things.

Posted: Tue Sep 18, 2007 2:48 am
by Kieran Huggins
Generating barcodes is dead easy - there are free typefaces. Each set of bars simply represents a character.

Reading barcodes is also dead easy, you use a barcode scanner! It reports the translated characters back as if it were a keyboard.

If you want to read them from an image (or you're just feeling masochistic) you could develop a mathematical method to compare spacing and line thicknesses. Sounds like something that also will have been done before. I can think of one example that does just that, but I highly doubt it's open source. Delicious Monster makes it, IIRC.