@cli.subcommand('Converts an input image to something QMK understands')
defpainter_convert_graphics(cli):
"""Converts an image file to a format that Quantum Painter understands.
This command uses the `qmk.painter` module to generate a Quantum Painter image defintion from an image. The generated definitions are written to a files next to the input -- `INPUT.c` and `INPUT.h`.
"""
# Work out the input file
ifcli.args.input!='-':
cli.args.input=normpath(cli.args.input)
# Error checking
ifnotcli.args.input.exists():
cli.log.error('Input image file does not exist!')
cli.print_usage()
returnFalse
# Work out the output directory
iflen(cli.args.output)==0:
cli.args.output=cli.args.input.parent
cli.args.output=normpath(cli.args.output)
# Ensure we have a valid format
ifcli.args.formatnotinvalid_formats.keys():
cli.log.error('Output format %s is invalid. Allowed values: %s'%(cli.args.format,', '.join(valid_formats.keys())))