diff options
| author | jacqueline <me@jacqueline.id.au> | 2024-06-12 17:54:40 +1000 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2024-06-12 17:54:40 +1000 |
| commit | 64bd9053a25297f7a442ca831c7da5b44bd33f84 (patch) | |
| tree | a90c6cad25a12028302ab1a5334510fba0229bae /lib/lvgl/scripts/image_viewer.py | |
| parent | 611176ed667c4ed7ee9f609e958f9404f4aee91d (diff) | |
| download | tangara-fw-64bd9053a25297f7a442ca831c7da5b44bd33f84.tar.gz | |
Update LVGL to v9.1.0
Diffstat (limited to 'lib/lvgl/scripts/image_viewer.py')
| -rwxr-xr-x | lib/lvgl/scripts/image_viewer.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/lvgl/scripts/image_viewer.py b/lib/lvgl/scripts/image_viewer.py new file mode 100755 index 00000000..2ce42a20 --- /dev/null +++ b/lib/lvgl/scripts/image_viewer.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python3 +from LVGLImage import LVGLImage +import argparse +import logging +import os + +logging.basicConfig(level=logging.INFO) + +parser = argparse.ArgumentParser(description="LVGL Binary Image Viewer") +parser.add_argument("file", help="the .bin image file") + +args = parser.parse_args() + +name, ext = os.path.splitext(args.file) +if ext != ".bin": + raise ValueError("Only support LVGL .bin image file") + +output = name + ".png" +img = LVGLImage().from_bin(args.file) +img.to_png(output) +logging.info(f"convert {args.file} to {output}") + +if os.name == "posix": + os.system(f"open {output}") +else: + try: + from PIL import Image + except ImportError: + raise ImportError("Need pillow package, do `pip3 install pillow`") + image = Image.open(output) + image.show(title=output) |
