mirror of
https://github.com/lvgl/lvgl.git
synced 2024-11-23 09:43:41 +08:00
feat(script): add tool to view bin image (#5451)
Signed-off-by: Xu Xingliang <xuxingliang@xiaomi.com>
This commit is contained in:
parent
12cd58419f
commit
0353bccc0a
31
scripts/image_viewer.py
Executable file
31
scripts/image_viewer.py
Executable file
@ -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)
|
Loading…
Reference in New Issue
Block a user