-
Notifications
You must be signed in to change notification settings - Fork 14
LispKit Draw Barcode
Library (lispkit draw barcode)
provides procedures for generating images of barcodes. Supported are Code 128, QR Code, Aztec, and PDF417 barcodes.
Code 128 is a high-density linear barcode defined in ISO 15417. It is used for alphanumeric or numeric-only barcodes and can encode any of the 128 ASCII characters. GS1-128 (formerly known as UCC/EAN-128) is a subset of Code 128 and is used extensively worldwide in retail, shipping and packaging industries as a product identification code.
QR codes (quick-response codes) are two-dimensional matrix barcodes, featureing black squares on a white background with fiducial markers, readable by imaging devices like cameras, and processed using Reed–Solomon error correction.
Aztec codes are matrix codes defined by ISO 24778. Named after the resemblance of the central finder pattern to an Aztec pyramid, Aztec codes have the potential to use less space than other matrix barcodes because they do not require a surrounding blank/"quiet" zone.
PDF417 is a stacked linear barcode format used in a variety of applications such as transport, identification cards, and inventory management. It is defined in ISO 15438.
(code128-image str height) [procedure]
(code128-image str height pad)
(code128-image str height pad scale)
(code128-image str height pad scale color)
(code128-image str height pad scale color backgr)
(code128-image str height pad scale color backgr ppi)
Returns a Code 128 barcode for the given string str and height in points as a bitmap image. pad defines the padding around the barcode in points (default: 0.0). It is possible to scale the barcode with scaling factor scale (default: 1.0). color defines the color of the barcode (default: #f
), backgr defines the background color (default: #f
). ppi determines the number of pixels per inch. By default, ppi is set to 72.
(define bc (code128-image "010123456789012815051231" 50 10))
(save-bitmap "barcode.png" bc 'png)
(qr-code-image str) [procedure]
(qr-code-image str corr)
(qr-code-image str corr scale)
(qr-code-image str corr scale color)
(qr-code-image str corr scale color backgr)
(qr-code-image str corr scale color backgr ppi)
Returns a QR Code matrix barcode for the given string str with 1 pixel matrix cells as a bitmap image. corr is the correction level, a symbol which can be one of: low
, medium
, quartile
, and high
(default: medium
). It is possible to scale the QR code with scaling factor scale (default: 2.0). color defines the color of the barcode (default: #f
), backgr defines the background color (default: #f
). ppi determines the number of pixels per inch. By default, ppi is set to 72.
(define qc (qr-code-image "http://lisppad.app" 'quartile 2.5))
(save-bitmap "qrcode.png" qc 'png)
(aztec-code-image str) [procedure]
(aztec-code-image str corr)
(aztec-code-image str corr compact?)
(aztec-code-image str corr compact? scale)
(aztec-code-image str corr compact? scale color)
(aztec-code-image str corr compact? scale color backgr)
(aztec-code-image str corr compact? scale color backgr ppi)
Returns an Aztec Code matrix barcode for the given string str with 1 pixel matrix cells as a bitmap image. corr is the correction level (default: 23.0). If compact? is provided, it can be used to select between a standard and a compact representation (default: ()
). It is possible to scale the Aztec code with scaling factor scale (default: 1.0). color defines the color of the barcode (default: #f
), backgr defines the background color (default: #f
). ppi determines the number of pixels per inch. By default, ppi is set to 72.
(define ac (aztec-code-image "[email protected]" #f '() 3.0))
(save-bitmap "azteccode.png" ac 'png)
(pdf417-code-image str) [procedure]
(pdf417-code-image str config)
(pdf417-code-image str config scale)
(pdf417-code-image str config scale color)
(pdf417-code-image str config scale color backgr)
(pdf417-code-image str config scale color backgr ppi)
Returns a PDF417 barcode for the given string str and barcode configuration config as a bitmap image. config is an association list supporting the following symbolic keys:
-
min-width
: Minimum width in points -
max-width
: Maximum width in points -
min-height
: Minimum height in points -
max-height
: Maximum height in points -
columns
: The number of columns (between 1 and 31) -
rows
: The number of rows (between 1 and 91) -
preferred-aspect-ratio
: Aspect ratio of the barcode -
compaction-mode
: Compaction mode (between 0 and 4) -
correction-level
: Compaction level (between 0 and 9) -
always-specify-compaction
: Is compaction mode always required? (bool)
It is possible to scale the PDF417 barcode with scaling factor scale (default: 1.0). color defines the color of the barcode (default: #f
), backgr defines the background color (default: #f
). ppi determines the number of pixels per inch. By default, ppi is set to 72.
(define pc (pdf417-code-image "[email protected]" '() 1.5))
(save-bitmap "pdf417.png" pc 'png)