23.7. Generating barcodes on the command line

The library includes a command line utility as an additional example on how to use the library.

This utility can be found in the "barcode/" directory. This utility should be used from the command line as the following example shows

$>php mkbarcode.php -b code39 ABC123 > barcode.png

The line above will create a barcode from the data string "abc123" using the Code 39 symbology and store the resulting image in the file "barcode.png".

Using the command utility as above assumes that the client version of PHP is available at the command line.

This utility has the following syntax

mkbarcode.php -b <symbology> [-r -h -c -o <output format> -m <width> -s <scale>\\ 
-y <height> -f <filename> ] datastring

Create the specified barcode
-b           What symbology to use, one of the following strings (case insensitive)
             UPCA
             UPCE
             EAN128
             EAN13
             EAN8
             CODE11
             CODE39
             CODE128
             CODE25
             CODEI25
             CODABAR
             BOOKLAND
-c           Add checkdigit for symbologies where this is optional
-o           Output format. 0=Image, 1=PS, 2=EPS
-m           Module width
-s           Scale factor
-h           Show this help
-f           Filename to write to
-r           Rotate barcode 90 degrees
-y height    Set height in pixels
-x           Hide the human readable text
--silent     Silent. Don't give any error mesages

If no filename is given the image will be sent back to the console which means it should be redirected to a file.