<- Back
barcode
Encode
Generate PNG from string
barcode -b '0123456789abcdABCD' -e code128 -g 400x225 -u pt -E | magick - -background white -alpha remove -alpha off out.png
Generate SVG from string
svgo is optional to reduce the size of the generated image. Be careful though, it might break the output!
barcode -b 'andreas-mausch.de' -e code128 -g 400x225 -u pt -S | svgo - > out.svg
Decode
via zbarimg
zbarimg code.png
Encoding types
Known encodings are (synonyms appear on the same line):
"ean", "ean13", "ean-13", "ean8", "ean-8"
"upc", "upc-a", "upc-e"
"isbn"
"39", "code39"
"39ext", "code39ext"
"128c", "code128c"
"128b", "code128b"
"128", "code128"
"128raw"
"i25", "interleaved 2 of 5"
"cbr", "codabar"
"msi"
"pls", "plessey"
"code93", "93"
"code11", "11"
Code39 vs. Code128
- A Code 128 barcode can encode a full 128 ASCII character set. A Code 39 barcode encodes 39 characters in total.
- Code 128 has a higher density than Code 39.
- Code 39 does not include a check digit, while Code 128 does. – https://www.dynamsoft.com/blog/insights/code-39-vs-code-128/
Differences between Code128 A, B, C
- 128A (Code Set A) – ASCII characters 00 to 95 (0–9, A–Z and control codes), special characters, and FNC 1–4
- 128B (Code Set B) – ASCII characters 32 to 127 (0–9, A–Z, a–z), special characters, and FNC 1–4
- 128C (Code Set C) – 00–99 (encodes two digits with a single code point) and FNC1 – https://en.wikipedia.org/wiki/Code_128#Subtypes
So if your string only contains digits, you can use Set C to save some space.
Error correction and checksum
Code128 does have a checksum character, while Code39 does not. However, neither has any type of error correction with redundant data, like in QR codes.