Barmaid is a command line tool to read and manipulate barcode and label BTW files as generated by BarTender. This is a work in progress created from the need to automatically adjust strings on a large amount of label files.
By default barmaid statically links its own copy of zlib. Thus compilation should be as simple as typing make
. Alternatively make SYS_ZLIB=1
links the installed version of zlib if available. The resulting binary can be found in the build
folder.
Info | Command |
---|---|
Show available options | barmaid -h |
Print file info | barmaid -e -v <file.btw> |
Save rendered png | barmaid -e -i image.png <file.btw> |
Extract container | barmaid -e -c container.bin <file.btw> |
BTW files contain the following sections:
- Header
- Contains bits of metadata, overall quite boring.
- barmaid stores the header in the prefix file.
- Preview images (PNG)
- One render of the label.
- One mask of the used area.
- Compressed binary container
- The container encodes the serialised label information.
The container seems to be using an encoding somewhat similar to BER (ASN.1) allowing for serialisation of different kinds of objects. So far string objects have been identified as being prefixed with the header FF FE FF XX
or FF FE FF FF YY YY
, where XX
encodes the number of UTF-16 (little endian) characters for up to 255 and YY YY
(encoded little endian) for up to 65535. e.g.: FF FE FF 03 41 00 42 00 43 00
encodes the string ABC
. It is common to find a lot of empty strings with a length of zero (FF FE FF 00
) in the container.
In addition to overwriting a string it is also possible to change the length of a string object by inserting or removing bytes, while adjusting the length field in the header accordingly. This even works if the container embeds binary blobs such as fonts and images.
barmaid 1.0 has been successfully used to process files of version 9.2 to version 2016. Though it failed for version 7.10.
The current barmaid 1.0 can only extract, but not build BTW files. barmaid 0.1 with limited features, yet build support is still available as barmaid_legacy.sh
.
Execute "barmaid_legacy.sh -e file_in.btw" to extract container and separate prefix.
Execute "barmaid_legacy.sh -c file_out.btw" to construct file_out.btw from fragments.