bardecode shell tool
The bardecode command provides an interface to the barcode reader toolkit from the shell. For example, the following command will scan an image file for barcodes and print the values:
bardecode -t any -m -f somefile.tif
Options are flags such as -m, which may or may not take an argument
long options are property name and value pairs, such as –MinSpaceBarWidth=2
options are:
-C max_length | Maximum length of barcode | |
-c min_length | Minimum length of barcode | |
-d scan_direction | Scan direction mask 1 = Left to Right, 2 = Top to Bottom 4 = Right to Left and 8 = Bottom to Top. default is 15. The scan direction mask controls the directions in which the barcode reader will look for a barcode. With this version it it now possible to scan for barcodes in any rotation with one call to the reader. | |
-f image_file | image_file can be of type TIF or JPG. JPG files must use the extension “.jpg” or “.jpeg” | |
-g | Process files and folders from the XML file specified with | |
-x flag. See below for more details. | ||
-i page_index | Page number of image indexed from 1 | |
-j jump | Frequency at which scan lines are sampled, default is 1 | |
-k skew tolerance | Skew tolerance 0 = off to 5 = any angle | |
-L oversample_sep | Distance between the line samples when over-sampling is used. Default value is 3. | |
-M min_space_width | Minimum allowed size in pixels for a space between bars | |
-m | Scan for multiple barcodes | |
-N noise_reduction | Advanced Noise Reduction (0 = off, typical value is 20) | |
-n noise_reduction | Noise Reduction level (0 = off, typical value is 20) | |
-O | Sample the scan lines in blocks of 3 with each line separated by oversample_sep lines (see below). | |
-o min_occurs | Minimum number of matching scan lines, default 2 | |
-P | Show page numbers | |
-p pref_occurs | Preferred number of matching scan lines, default 5 | |
-q quiet_size | Number of pixels wide for the quiet zone around bar code | |
-R pattern | Barcodes must match regular expression defined by pattern -r x1,y1,x2,y2,m | Rectangle for scanning (see below for details) |
-S file_template: | Split a multi-page TIF file into smaller TIF files. | |
The first page of each new file will contain a barcode | ||
The template must include %d to index the files | ||
e.g. file%d.tif. Must be used with -m flag. | ||
-T color_threshold | Set the color threshold | |
-t barcode_types | Specifies the types of barcodes to read, barcode_types is one or more of “code39”, “code128”, “upca”, “upce”, “ean8”, “code25”, “ean13” and “codabar” joined together with the | character. | |
-t any | Searches for a barcode of any type e.g “code39|code128” | |
-u upper_ratio | Defunct flag | |
-w | Print TIF Warnings to STDERR | |
-X xml_output | Output results to specified XML file (see below) | |
-x xml_input | Load settings from specified XML file (see below) |
The long options give access to all the features of the toolkit.
Supported long options properties are: AllowDuplicateValues, Code39Checksum,
Code39NeedStartStop, ColorThreshold, ConvertEAN13ToUPCE, Debug, Despeckle,
ErrorCorrection, ExtendedCode39, LineJump, MaxLength, MedianFilter, MinLength,
MinOccurrence, MinSeparation, MinSpaceBarWidth, MultipleRead, NoiseReduction
OverSamplingSeparation, PrefOccurrence, QuietZoneSize, PageNo, Pattern,
ReadCodabar, ReadCode128, ReadCode25, ReadCode25ni, ReadCode39,ReadDataMatrix
ReadEAN8, ReadEAN13, ReadNumeric, ReadPatchCodes, ReadPDF417, ReadUPCA
ReadUPCE, ScanDirection, ShowCheckDigit, SkewTolerance, TifSplitMode
TifSplitPath and UseOverSampling.
Please refer to the product documentation for descriptions and appropriate
values.
Rectangle argument:
The top left hand corner of an image is the origin and (x1,y1) (x2,y2) define the
top left and bottom right corners of the rectangle to be searched – with the
measurements taken in either pixels or a percentage of the width/height of the image.
If m = 0 then the units are pixels and if m = 1 then the units are as a percentage.
Example: To search top right hand quarter of an image use -m50,0,100,50,1
XML Input and Output
Settings and results can be stored in XML format. Multiple layers of settings
can be specified, with the toolkit trying each successive layer until a barcode
is found. For more details please refer to the manual pages for LoadXMLSettings
and SaveResults. If the -g flag is also used then any files or folders specified
in the input file are processed, as described in the manual page for ProcessXML.
Examples:
Scan for a Code 39 barcode in a portrait orientation image:
bardecode -f file.tif -t code39 -d 5
Using long options:
bardecode -f file.tif –ReadCode39=1 –ScanDirection=5
Scan for a Code 39 barcode in a landscape orientation image:
bardecode -f file.tif -t code39 -d 10
Scan for a Code 128 or UPC-A barcode in an image of poor quality:
bardecode -n 20 -f file.tif -t “code128|upca”
Split a multi-page TIF file into smaller files, each with a barcode on page 1
bardecode -t code39 -m -S output%d.tif -f multipage.tif