barcode ?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
myharshdesigner
Forum Commoner
Posts: 43
Joined: Sat Apr 21, 2007 8:23 pm

barcode ?

Post 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
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Post by VladSun »

There are 10 types of people in this world, those who understand binary and those who don't
User avatar
Zoxive
Forum Regular
Posts: 974
Joined: Fri Apr 01, 2005 4:37 pm
Location: Bay City, Michigan

Post by Zoxive »

*Cough* http://www.google.com/search?q=php+barcodes

As for Reading them, your going to need well, a Reader.
ReDucTor
Forum Commoner
Posts: 90
Joined: Thu Aug 15, 2002 6:13 am

Post 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.
myharshdesigner
Forum Commoner
Posts: 43
Joined: Sat Apr 21, 2007 8:23 pm

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post 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?
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
ReDucTor
Forum Commoner
Posts: 90
Joined: Thu Aug 15, 2002 6:13 am

Post 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?
myharshdesigner
Forum Commoner
Posts: 43
Joined: Sat Apr 21, 2007 8:23 pm

Post 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
ReDucTor
Forum Commoner
Posts: 90
Joined: Thu Aug 15, 2002 6:13 am

Post 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.
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post 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.
Post Reply