Skip to content

Latest commit

 

History

History

barcodes

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

README.md

Barcodes

Makes one barcode of every kind std.barcodes knows, saves each as an image, then loads the image back and checks that the barcode found in it holds the text it was made from. The images below are this example's output.

adm run encoding/barcodes/main.adm                # writes into barcodes-out/
adm run encoding/barcodes/main.adm -- some/dir    # writes into some/dir

Making a barcode and reading one are a call each, in main.adm:

let symbol = try encode("https://adm-lang.dev", Symbology.Qr)
try symbol.toImage(scale = 5).save("qr.png")

for let (_, found) in decode(try load("qr.png")) {
	println("{found.symbology}: {found.text}")
}

Two-dimensional codes

Kind Text Image
QR https://adm-lang.dev/?from=barcodes QR code
Micro QR ADM 2026 Micro QR code
Data Matrix Data Matrix: 0123456789 Data Matrix code
Aztec Aztec Code, hello! Aztec code
PDF417 PDF417 carries whole paragraphs of text. PDF417 code
MicroPDF417 MicroPDF417 MicroPDF417 code

Linear codes

Kind Text Image
EAN-13 5901234123457 EAN-13 barcode
EAN-8 96385074 EAN-8 barcode
UPC-A 036000291452 UPC-A barcode
UPC-E 01234565 UPC-E barcode
Code 128 Code 128 / ADM Code 128 barcode
Code 39 CODE 39 Code 39 barcode
Code 93 Code 93! Code 93 barcode
ITF 12345670 ITF barcode
Codabar A40156B Codabar barcode

Read back from a JPEG

JPEG is lossy, so its blurred edges test the reader. This QR code holds Read back from a JPEG, with a higher error correction level:

QR code saved as JPEG

Several barcodes in one image

decode finds every barcode in an image. This sheet holds a QR code, a Data Matrix code, an Aztec code and a Code 128 barcode, and one call reads all four:

Four barcodes on one sheet