1
0
Fork 0

Add raw output option for QGF/QFF files. (#18998)

This commit is contained in:
Nick Brassel 2022-11-09 02:47:07 +11:00 committed by GitHub
parent bb0856d231
commit 9daf77b593
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 6 deletions

View file

@ -15,6 +15,7 @@ from PIL import Image
@cli.argument('-f', '--format', required=True, help='Output format, valid types: %s' % (', '.join(valid_formats.keys())))
@cli.argument('-r', '--no-rle', arg_only=True, action='store_true', help='Disables the use of RLE when encoding images.')
@cli.argument('-d', '--no-deltas', arg_only=True, action='store_true', help='Disables the use of delta frames when encoding animations.')
@cli.argument('-w', '--raw', arg_only=True, action='store_true', help='Writes out the QGF file as raw data instead of c/h combo.')
@cli.subcommand('Converts an input image to something QMK understands')
def painter_convert_graphics(cli):
"""Converts an image file to a format that Quantum Painter understands.
@ -53,6 +54,12 @@ def painter_convert_graphics(cli):
input_img.save(out_data, "QGF", use_deltas=(not cli.args.no_deltas), use_rle=(not cli.args.no_rle), qmk_format=format, verbose=cli.args.verbose)
out_bytes = out_data.getvalue()
if cli.args.raw:
raw_file = cli.args.output / (cli.args.input.stem + ".qgf")
with open(raw_file, 'wb') as raw:
raw.write(out_bytes)
return
# Work out the text substitutions for rendering the output data
subs = {
'generated_type': 'image',