summaryrefslogtreecommitdiffstats
path: root/README.md
blob: 425cf39f7e57c2b4ebe8cbadec1d584339bb2633 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# qlprint
Command-line utility for printing to Brother QL series label printers.

Tested with:
  * QL-570
  
Hopefully also works with:
  * QL-500/550
  * QL-560
  * QL-580N
  * QL-650TD
  * QL-700
  * QL-710W
  * QL-720W
  * QL-1050
  * QL-1060N

Inspired, though not derived from, the [ql570](https://github.com/sudomesh/ql570.git) tool. Licensed under the GPLv3 nevertheless.

## Building
Requires `GNU make` and `libpng` (with development headers), with `pkg-config` to locate libpng headers & libs.

Simply run `make` in this directory, e.g.:
```
$ make
cc -std=c11 -Wall -Wextra -g -Iinclude -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200809 -I/usr/include/libpng12 -c src/main.c -o build/main.o
cc -std=c11 -Wall -Wextra -g -Iinclude -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200809 -I/usr/include/libpng12 -c src/ql.c -o build/ql.o
cc -std=c11 -Wall -Wextra -g -Iinclude -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200809 -I/usr/include/libpng12 -c src/loadpng.c -o build/loadpng.o
cc -lpng12 build/main.o build/ql.o build/loadpng.o -o build/qlprint
$
```

## Running
```
Syntax:
  qlprint [-p lp] -i
          [-p lp] [-m margin] [-a] [-C|-D] [-W width] [-L length] [-Q] [-n num] [-t threshold] png...
Where:
  -p lp         Printer port (default /dev/usb/lp0)
  -i            Print status information only, then exit
  -m margin     Margin (dots)
  -a            Enable auto-cut
  -C            Request continuous-length-tape when printing (error if not)
  -D            Request die-cut-labels when printing (error if not)
  -W width      Request particular width media when printing (error if not)
  -L length     Request particular length media when printing (error if not)
  -Q            Prioritise quality of speed
  -n num        Print num copies
  -t threshold  Threshold for black-vs-white (default 128, i.e. 0-127=black)
  png...        One or more png files to print

```

The PNG files are converted to monochrome internally. The black-vs-white
threshold for this conversion may be tuned with the `-t threshold` argument.

Image height is limited to the capability of the printer (720 for most, 1296
for 1050/1060N models). Attempting to print larger images will fail.

On successful printing, the exit code is zero; in case of any error, the exit
code is non-zero and an error message is printed to stderr.

## Examples

### Show printer status information
Here with a narrow continuous-length-tape cartridge loaded.
```
$ ./build/qlprint -i
          Printer: QL-570
             Mode: no-auto-cut
           Errors: none
       Media type: continuous-length-tape
 Media width (mm): 29
$
```

### Printing with auto-cutter enabled:
```
$ ./build/qlprint -a example.png
example.png (135x135) OK
$
```

### Printing two images, cutting only once
```
$ ./build/qlprint -a example.png example.png
example.png (135x135) OK
example.png (135x135) OK
$
```

### Printing two copies of the one image, cutting after each
```
$ ./build/qlprint -a -n 2 example.png
example.png (135x135) OK
example.png (135x135) OK
$
```

### Print only on the correct media type
Assuming a continuous-length-tape cartridge is installed:
```
$ ./build/qlprint -C example.png
example.png (135x135) OK
$
```
...otherwise:
```
$ ./build/qlprint -C example.png
Printer reported error(s): replace-media
$
```