code128
barwidth string [>
output-file]
Code128 generates barcode images in JPG (or GIF, if you don’t
have a copy of libjpeg
on your system) using
Boutell.com’s
GD graphics library. It takes
two arguments – the width of the smallest bar in the output (typically
1; the title image on this page uses 2) in pixels, and the string you wish
to generate a barcode of. It encodes that string using the Code 128
barcode format, and dumps the resulting image to standard out.
There are approximately a million versions of GD out there, but if your version supports PNG images, it will produce a png, otherwise if it supports JPEGs, it will produce a jpeg, otherwise otherwise it will produce a GIF.
barwidth
long per character,
plus 55 barwidth for the message envelope.Code128 uses my configuration
system to configure itself for building on various platforms. To
build the code, untar the archive, run configure.sh
, then run
a make
.
mkcodes
, which is used to make the file table.c
which contains
codeAmap[]
, codeBmap[]
, and controlmap[]
(codeC doesn’t use
lookups; the 100 CODEC points are 0..99 so no lookup is needed.))It turns out that when I originally wrote this code I’d completely misread the checksum generation algorithm, so instead of code128 barcodes I was generating orc128 barcodes. So, as part of a small software death march to updating the configuration to work with a more uptodate version of libgd (which was a pain because libgd has gone not only to GNU autoconfigure, but has – at least on Unix – abandoned make for cmake, so I couldn’t even salvage a GNU Makefile.in but had to create one from scratch instead) I reworked the checksum computation so that it actually works.
Other features in 0.4 include changing the copyright to a 3-clause BSD-style one and changing the output format of the barcode image to (depending on libgd support) PNG, then Jpeg, and finally (the finally free-to-use) GIF format.