4

I am working to integrate POS system to my site. So I want to generate barcode. I am using SKU as the data fields to encode the formate is XXXXX-XXX-XXX-XXX.

X is a digit from 0 to 9 so after doing research I found code 128 is the best correct me if I am wrong. The problem with size, The label on items are 2' by 3 1/2' inches, when I generate barcode using barbecue and resize the image the scanner cannot read the barcode. So could you please explain what is the size constrains and what is the smallest size that I can get in inches.

Terry Burton
  • 2,801
  • 1
  • 29
  • 41
Mohd Alomar
  • 953
  • 1
  • 13
  • 30
  • 2
    The the "XXXXX-XXX-XXX-XXX" format rigid? Code 128 has a double density numeric mode that can encode strings of digits efficiently. Unfortunately the dashes will be preventing this optimisation. – Terry Burton Mar 23 '16 at 12:58
  • so removing dashes will decrease the size, what if a reduce the barcode dimensions, suppose the barcode size is 3 per 1 inches if I reduces to to 1.5 per 0.5 inches can the barcode reader read it or I should not miss with the dimensions manually ? I did a test with my phone but it couldn't read it. and I didn't receive the barcode reader yet. – Mohd Alomar Mar 23 '16 at 15:42
  • 1
    Removing the dashes will produce a barcode containing fewer bars and spaces which give you flexibility. – Terry Burton Mar 23 '16 at 15:55
  • 1
    If your printing process has a good resolution then in general it is best to aim the make the barcode occupy the maximum possible width that fits comfortably within the scanner's field of view (whilst observing some whitespace at either side of the symbol). – Terry Burton Mar 23 '16 at 15:56
  • If your printing process is low-resolution and the output small then you may need to carefully align and scale things such that the X-dimension (width of a narrow bar/space) is some multiple of the output pixel width to prevent errors from being introduced due to pixel-grazing. – Terry Burton Mar 23 '16 at 15:56
  • 1
    The following answer gives more detail about producing robust output: http://stackoverflow.com/a/31814413/2568535 – Terry Burton Mar 23 '16 at 15:58
  • Thanks all I was able to change size but because barbecue uses 72 px per inch the quality is bad and the barcode became unreadable, then I used another library the give me flexibility on dimension and resolution I got the target dimensions with readable barcode. Can you write a good answer for this to mark it as accepted answer as still I didn't get it 100% to be able to explain – Mohd Alomar Mar 24 '16 at 09:47
  • 1
    I'll work up an answer this weekend. Thanks. – Terry Burton Mar 24 '16 at 13:47

2 Answers2

9

Production of high-quality barcodes requires that the printing process is accurately controlled from end to end. Here I provide guidance that is specific to Code 128 as well as additional guidance that is applicable to linear barcodes in general.

Optimisation of Code 128

There are no mandated size limits imposed on generic uses of Code 128, however applications of Code 128 within particular industries do define such constraints. For your in-house purposes it is really only practical constraints such as the fidelity of your printer and the capabilities of your scanner that will dictate an upper and lower size limit.

You should ensure that the data can be represented within the Code 128 as compactly as possible as this will reduce the required number of bars and space elements, which will provide greater flexibility when sizing the symbol. For example, using numeric-only data will enable efficient use of the double-density "Mode C" digit compression. See this answer for more detail.

This begs the question of whether it is possible for you to drop the dashes from your SKUs and reintroduce then within your application after scanning the symbols? Consider the different widths of Code 128s for your SKUs with and without dashes to see the impact of this:

Code 128 with dashes

Code 128 without dashes

Also, a quiet zone of at least ten times the X-dimension (width of a narrow bar) must be maintained at either end of the symbol:

Parts of a Code 128 symbol

The quiet zone should be considered an integral part of the Code 128 symbol as show by the above image.

General guidance for optimisation of linear barcodes

For closed applications (where you have complete control of both the printing and the scanning of the symbol), aim to maximise the width of the barcode provided that it fits comfortably within the scanner's field of view.

For open applications involving multiple trading partners with their own equipment and processes (such as general retail or logistics), ensure that the printed symbol's X-dimension and height fall within the minimum and maximum constraints defined by the relevant application standard.

In all cases, avoid anti-aliasing since many scanners perform edge to similar edge measurements that work best with clearly-defined, high-contrast edges. Anti-aliasing commonly results from scaling up an undersized bitmap image, but it might also occur in the absence of scaling as a result of features designed to improve the appearance of "jaggies" in regular images.

It is especially important to ensure that the intended X-dimension of the output symbol is an integer multiple of the printer's pixel size. Failure to do this will result in instability of element (bars and spaces) widths — elements intended to have the same width may differ by one printed dot. This is due to the set of available X-dimensions being solely determined by the number of printed dots per narrow element, and you cannot allocate fractional dots to a bar.

The specification for Code 128 (ISO/IEC 15417) imposes the following requirements on symbol generation software:

Graphics software used to create bar codes on pixel-based printers must scale each bar and space exactly to the pixel pitch of the printer being used. For edge to similar edge decodable symbologies like Code 128 the number of pixels comprising each symbol character must be a fixed and constant integer multiple of the number of modules in the symbol character.

A corollary of this is that the physical symbol size must grow in quantums according to the dot pitch of the printer. Therefore, it is not possible to meet the dimensional constraints required for each application using every model of printer. A well-aligned symbol cannot simply be a bit bigger or smaller, so as to meet some nominal size or to optimally fill a desired space, whilst remaining properly fitted to the physical printing characteristics of the output device.

For example, the GS1 General Specifications for 2D symbols on trade items "not scanned at POS, retail, distribution or regulated healthcare" (SST 4) defines an allowable range for the X-dimension of between 0.380 - 0.495mm. This can be met by a bespoke 5 dpmm (dots per mm) printer by printing two dots per narrow bar, but it is completely unachievable with a more common 8 dpmm printer even though it is a higher resolution device: Three 0.125mm dots would be undersized; four 0.125mm dots would be oversized.

Also, when rasterising a vector path description it is essential to ensure that the origin is properly aligned with the device's dot grid. This way you can avoid bars that are intended to have the same width from being rasterised to differing widths due to pixel-grazing, as demonstrated in this image in which an identical line width is rendered to different printed widths when rendered at different X coordinates:

Pixel grazing

Failure to follow the above advice will result in an image that has certain bars thickened, as demonstrated by the following impressions:

Same symbol with good and bad grid-fitting

The leftmost image represents a high-resolution impression; the middle image represents the same symbol rendered as a low-resolution impression (zoomed for scale) that has been correctly grid-fitted and will scan perfectly, because despite the lower resolution the bar-space pattern is identical to the leftmost image; the rightmost image is the same low-resolution impression but in this case has been incorrectly grid-fitted and will not scan because the bar-space pattern has been corrupted.

As an aside, notice that when the middle image has been scaled up (for demonstration purposes), anti-aliasing has been applied only to the text but not to the bars. As mentioned earlier, this is critical for ensuring that the decoding process is provided with accurate distances between the element of the symbol.

With certain printing processes it may also be necessary for the software to compensate for "print growth" (due to ink bleed and other imperfections in the process) by reducing the width of all bars by a small, fixed amount whilst maintaining accurate edge-to-edge spacing.

ISO/IEC 15417 describes this latter process as follows:

General purpose printing software designed to support a wide range of printers should provide the user the capability of adjusting the X dimension and bar width growth or loss.

The use of bar width reduction should be restricted to compensating for physical imperfections in the printing process, such as ink feathering. Depending upon the technology, the degree of bar width adjustment may require periodic re-calibration. Bar width reduction cannot adequately compensate for pixel-grazing that is the result of an improperly aligned and grid-fitted image description.

Even if you precisely follow all of the above advice, some devices and drivers contain advanced features (beyond regular anti-aliasing) that can defeat an attempt to print the perfect barcode symbol, especially when rasterisation involves scaling the image, even by an integer factor:

  • Some RIPs may attempt to preserve the width of lines to ensure uniform "heaviness" of line art, but in doing this they will adjust the relative ratio of bar widths to space widths. It can be difficult for the human eye to observe this effect with barcodes. It might be considered to be a variation of the print growth phenomenon but in which bars are affected by some uniform scale factor rather than a fixed amount.
  • Some RIPs may consider high-frequency, regular lines within a region to be a form of shading and then attempt to preserve the perceived level of gray, either by introducing additional lines of the original width to maintain the line distance when scaling or by entirely replacing the lines within the region with a halftone screen.

In summary, where the target device's resolution is known, generate a source barcode image with an X-dimension that is actually achievable, is well grid-fitted, and preferably where the source image pixels or path description aligns directly to device dots in order to to avoid all unnecessary processing of the image. Always re-verify the printed symbols whenever any component of the printing system (hardware or software) changes.

This answer demonstrates what happens when these process controls aren't followed.

Terry Burton
  • 2,801
  • 1
  • 29
  • 41
0

The short answer is for that purpose I would use free and opensource "Zint barcode studio" with "Code 128" symbology and manually generate and check all the barcode images I need for my website.

For a more broad answer: There are many barcodes and a lot of software available but for practical purposes there are a few limitations:

  1. You generally want to use a universal barcode, not some specialized stuff like UPC/EAN or something and definitely not something you would come up with yourself.
  2. You want to be able to use the cheapest and the most abundant second hand workhorse scanners on the market that are already available at any at least somewhat modern warehouse. Something like Honeywell 1250 or even cheaper. Why even bother going with a linear barcode otherwise when something like DataMatrix can not be beat by any of them in terms of density as well as error correction potential and extra features.
  3. You want a barcode to be as idiot-proof as possible and to resist partial scans or damaged barcode scans as much as it possibly can.

N2 leaves you pretty much with only Codabar, Code11, Code32, Code93, Code128, the EANs/UPCs, GS1 Databar, and the i2of5. All the GS1 stuff is too new and is out of the question - only relatively modern scanners support them. It also assumes a specific data format as well and with some implementations and scanners it can potentially happen to be very annoying. Code93 is not supported by some chinese scanner models and it is generally more rare. EAN/UPC violate requirement N1. i2of5 code has no start/stop symbols and violates requirement N3. Codabar and Code 11 can only encode digits and a couple of extra characters but having the ability to use your own special format would provide additional protection against some unrelated barcodes therefore helping in tearms of N3. Out of the remaining codes Code39 and Code128 the seccond provides much higher resistance against damaged lines and overall barcode density is significantly higher.

That is why I see that Code128 is the best linear barcode out there. And for the cases when really really old and crappy scanners from the early 90s are used, the simple Code39 is a somewhat decent backup option that can easilly be generated using some free TrueType font.

Once you have decided on Code128 it is good to know that according to ISO 15417 there are 3 variants of the code depending on the range of symbols you need. The 128A is pretty useless with its control characters but using 128C as it is or properly mixed with 128B parts can provide much more compact barcodes (actually it would be the most compact barcode compared to all the other barcodes I listed above). But at the same time some very crappy scanners may not read the mixed symbologies and require the whole barcode to be either 128C (pairs of digits only) or 128B (upper and lower case letters and digits). Therefore trying different software, playing around with it for a bit and examining the results is also important.

After that the only thing left to do is to make sure that you have a high contrast (preferably black lines on white background, some scanners do not read barcodes with inverted colors), reserve a decent clean free space margins around the barcode, print decently sized barcodes, and keep all your computer screens, labels and scanning heads at least relatively clean.

mrKirushko
  • 60
  • 1
  • 6