Reputation: 79458
I've been searching around for how to understand how to generate a bar code and haven't found any useful information.
Basically, a bar code has these features:
I would like to know what the specification is for the widths of the bars. That's it. I can find information regarding the data to put into a bar code. I just haven't found any information on how you translate some arbitrary data into the different black and white bars of different widths. I would like to know how many different widths there are as well (for each black and white bars).
Upvotes: 0
Views: 186
Reputation: 1776
The USPS supports both Code 128B and Code 39 barcodes. For international mail it is recommended that you use Code 39. The different symbologies (of which, Code 128 and Code 39 are but two examples) use very different encoding methods and so the answer for how a number "8" is made, for example, is dependent on the symbology selected.
In order to know what the widths of bars and spaces there are for each character, you need to know what symbology you are talking about first. After that point, Wikipedia is your friend. A good tip here is not to think of them in terms of widths, but as ratios.
The dark and light areas of a barcode are proportional to one another because it is impossible to know how far away the scanner will be from the printed code. So you don't want software that measures black bar widths or white spaces in terms of millimeters or even pixels. Instead you want to imagine the ability to print the tiniest barcode as dots and then use your printing mechanism to scale.
For example: the Code 39 representation of the number "8" is a thick bar followed by a thin space followed by a thin bar followed by a thick space followed by a thin bar followed by a thin space followed by a thick bar followed by a thin space followed by a thin bar followed by a thin space. That's almost as painful to read as it was to write.
So to avoid all that, I just think of the ratio between thin and thick for Code 39 to be 1:3 and use ones to represent bars (black dots) and zeroes to represent white spaces. In that context, a Code 39 number "8" looks like "1110100010111010". There is no sense trying to figure out widths in microns or millimeters or angstroms. You can put a barcode on a tardigrade or a corn field if you have the right equipment. The widths will change, but the ratios will not.
To illustrate I have used our Code 39 number "8" as an example:
<table><tr><td><span><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAACCAQAAADLaIVbAAAANUlEQVQIHQEqANX/AQD/AAAAAAAAAAAAAP8AAAABAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAARVICA/z3WM0AAAAASUVORK5CYII=" width="30" height="70"><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAACCAQAAADLaIVbAAAANUlEQVQIHQEqANX/Af//AAAAAAAAAAAAAAEAAAD/AAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAajEDAm49ReYAAAAASUVORK5CYII=" width="30" height="70"><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAACCAQAAADLaIVbAAAANUlEQVQIHQEqANX/AQD/AAAAAAAAAAAAAP8AAAABAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAARVICA/z3WM0AAAAASUVORK5CYII=" width="30" height="70"><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAACCAQAAADLaIVbAAAANUlEQVQIHQEqANX/Af//AAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAUS0CAuSD38gAAAAASUVORK5CYII=" width="30" height="70"></span></td><td width=150px>
The barcode on the left is five times wider than the one on the right. (same code)</td><td>
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAACCAQAAADLaIVbAAAANUlEQVQIHQEqANX/AQD/AAAAAAAAAAAAAP8AAAABAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAARVICA/z3WM0AAAAASUVORK5CYII=" width="6" height="70"><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAACCAQAAADLaIVbAAAANUlEQVQIHQEqANX/Af//AAAAAAAAAAAAAAEAAAD/AAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAajEDAm49ReYAAAAASUVORK5CYII=" width="6" height="70"><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAACCAQAAADLaIVbAAAANUlEQVQIHQEqANX/AQD/AAAAAAAAAAAAAP8AAAABAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAARVICA/z3WM0AAAAASUVORK5CYII=" width="6" height="70"><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAACCAQAAADLaIVbAAAANUlEQVQIHQEqANX/Af//AAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAUS0CAuSD38gAAAAASUVORK5CYII=" width="6" height="70"></td></tr></table>
Upvotes: 1