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/dirMaking 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}")
}
| Kind | Text | Image |
|---|---|---|
| EAN-13 | 5901234123457 |
![]() |
| EAN-8 | 96385074 |
![]() |
| UPC-A | 036000291452 |
![]() |
| UPC-E | 01234565 |
![]() |
| Code 128 | Code 128 / ADM |
![]() |
| Code 39 | CODE 39 |
![]() |
| Code 93 | Code 93! |
![]() |
| ITF | 12345670 |
![]() |
| Codabar | A40156B |
![]() |
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:
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:
















