From adff74cc46fd69abc89438e0e8a1d6bfc45ed29f Mon Sep 17 00:00:00 2001 From: Chang Date: Sun, 9 Sep 2018 12:30:51 +0800 Subject: [PATCH 1/2] add support for 16:10 desktop aspect ratio --- himawaripy/__main__.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/himawaripy/__main__.py b/himawaripy/__main__.py index b86d9c7..547da77 100755 --- a/himawaripy/__main__.py +++ b/himawaripy/__main__.py @@ -87,6 +87,8 @@ def parse_args(): group.add_argument("-o", "--offset", type=int, dest="offset", default=10, help="UTC time offset in hours, must be less than or equal to +10") + parser.add_argument("--auto-aspect-ratio", action="store_true", dest="auto_aspect_ratio", default=False, + help="better for 16:10 aspect ratio desktop. works only on default level!") parser.add_argument("-l", "--level", type=int, choices=[4, 8, 16, 20], dest="level", default=4, help="increases the quality (and the size) of each tile. possible values are 4, 8, 16, 20") parser.add_argument("-d", "--deadline", type=int, dest="deadline", default=6, @@ -168,6 +170,20 @@ def thread_main(args): tile = Image.open(io.BytesIO(tiledata)) png.paste(tile, (WIDTH * x, HEIGHT * y, WIDTH * (x + 1), HEIGHT * (y + 1))) + if args.auto_aspect_ratio and args.level == 4: + MARGIN = 166 + + height = int(png.height + MARGIN * 2) + width = int(height * 1.6) + + png_new = Image \ + .new('RGB', (width, height), 0) + + png_new.paste(png, (int(width / 2 - png.width / 2), MARGIN)) + + del png + png = png_new + for file in iglob(path.join(args.output_dir, "himawari-*.png")): os.remove(file) From 1a0e7ec2886e0bb4ddf5de0ce9ce5a38d29964b3 Mon Sep 17 00:00:00 2001 From: Chang Date: Sun, 9 Sep 2018 12:33:26 +0800 Subject: [PATCH 2/2] update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index ed04fe3..3b90fcf 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,8 @@ optional arguments: -o OFFSET, --offset OFFSET UTC time offset in hours, must be less than or equal to +10 + --auto-aspect-ratio better for 16:10 aspect ratio desktop. works only on + default level! -l {4,8,16,20}, --level {4,8,16,20} increases the quality (and the size) of each tile. possible values are 4, 8, 16, 20