brother_ql_create new CLI argument --compress
* create_label() now accepts a new keyword argument compress. The default is False → no compression if not set manually. This will speed-up the label creation in many cases at the expense of larger file sizes. Set to True if you don't care about processing time but want to store the generated label files. * The brother_ql_create CLI offers this via the new argument --compress. New default (if not set): no compression.
This commit is contained in:
@@ -63,7 +63,8 @@ giving:
|
||||
|
||||
usage: brother_ql_create [-h] [--model MODEL] [--label-size LABEL_SIZE]
|
||||
[--rotate {0,90,180,270}] [--threshold THRESHOLD]
|
||||
[--dither] [--no-cut] [--loglevel LOGLEVEL]
|
||||
[--dither] [--compress] [--no-cut]
|
||||
[--loglevel LOGLEVEL]
|
||||
image [outfile]
|
||||
|
||||
positional arguments:
|
||||
@@ -87,6 +88,8 @@ giving:
|
||||
between black and white pixels.
|
||||
--dither, -d Enable dithering when converting the image to b/w. If
|
||||
set, --threshold is meaningless.
|
||||
--compress, -c Enable compression (if available with the model).
|
||||
Takes more time but results in smaller file size.
|
||||
--no-cut Don't cut the tape after printing the label.
|
||||
--loglevel LOGLEVEL Set to DEBUG for verbose debugging output to stderr.
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ def main():
|
||||
parser.add_argument('--rotate', '-r', choices=('0', '90', '180', '270'), default='auto', help='Rotate the image (counterclock-wise) by this amount of degrees.')
|
||||
parser.add_argument('--threshold', '-t', type=float, default=70.0, help='The threshold value (in percent) to discriminate between black and white pixels.')
|
||||
parser.add_argument('--dither', '-d', action='store_true', help='Enable dithering when converting the image to b/w. If set, --threshold is meaningless.')
|
||||
parser.add_argument('--compress', '-c', action='store_true', help='Enable compression (if available with the model). Takes more time but results in smaller file size.')
|
||||
parser.add_argument('--no-cut', dest='cut', action='store_false', help="Don't cut the tape after printing the label.")
|
||||
parser.add_argument('--loglevel', type=lambda x: getattr(logging, x), default=logging.WARNING, help='Set to DEBUG for verbose debugging output to stderr.')
|
||||
args = parser.parse_args()
|
||||
@@ -53,11 +54,11 @@ def main():
|
||||
|
||||
qlr.exception_on_warning = True
|
||||
|
||||
create_label(qlr, args.image, args.label_size, threshold=args.threshold, cut=args.cut, rotate=args.rotate, dither=args.dither)
|
||||
create_label(qlr, args.image, args.label_size, threshold=args.threshold, cut=args.cut, rotate=args.rotate, dither=args.dither, compress=args.compress)
|
||||
|
||||
args.outfile.write(qlr.data)
|
||||
|
||||
def create_label(qlr, image, label_size, threshold=70, cut=True, dither=False, **kwargs):
|
||||
def create_label(qlr, image, label_size, threshold=70, cut=True, dither=False, compress=False, **kwargs):
|
||||
|
||||
label_specs = label_type_specs[label_size]
|
||||
dots_printable = label_specs['dots_printable']
|
||||
@@ -146,7 +147,7 @@ def create_label(qlr, image, label_size, threshold=70, cut=True, dither=False, *
|
||||
pass
|
||||
qlr.add_margins(label_specs['feed_margin'])
|
||||
try:
|
||||
qlr.add_compression(True)
|
||||
if compress: qlr.add_compression(True)
|
||||
except BrotherQLUnsupportedCmd:
|
||||
pass
|
||||
qlr.add_raster_data(im)
|
||||
|
||||
Reference in New Issue
Block a user