forked from glencoesoftware/isyntax2raw
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathisyntax2raw.py
More file actions
106 lines (94 loc) · 2.83 KB
/
isyntax2raw.py
File metadata and controls
106 lines (94 loc) · 2.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# encoding: utf-8
#
# Copyright (c) 2019 Glencoe Software, Inc. All rights reserved.
#
# This software is distributed under the terms described by the LICENCE file
# you can find at the root of the distribution bundle.
# If the file is missing please request a copy by contacting
# support@glencoesoftware.com.
import click
import logging
from .. import WriteTiles
def setup_logging(debug):
level = logging.INFO
if debug:
level = logging.DEBUG
logging.basicConfig(
level=level,
format="%(asctime)s %(levelname)-7s [%(name)16s] "
"(%(thread)10s) %(message)s"
)
@click.group()
def cli():
pass
@cli.command(name='write_tiles')
@click.option(
"--tile_width", default=512, type=int, show_default=True,
help="tile width in pixels"
)
@click.option(
"--tile_height", default=512, type=int, show_default=True,
help="tile height in pixels"
)
@click.option(
"--resolutions", type=int,
help="number of pyramid resolutions to generate [default: all]"
)
@click.option(
"--max_workers", default=4, type=int,
show_default=True,
help="maximum number of tile workers that will run at one time",
)
@click.option(
"--batch_size", default=250, type=int, show_default=True,
help="number of patches fed into the iSyntax SDK at one time"
)
@click.option(
"--fill_color", type=click.IntRange(min=0, max=255), default=0,
show_default=True,
help="background color for missing tiles (0-255)"
)
@click.option(
"--nested/--no-nested", default=True, show_default=True,
help="Whether to use '/' as the chunk path separator"
)
@click.option(
"--linear16to8", default=False, show_default=True,
help="apply built-in linear 16 to 8 bit filter"
)
@click.option(
"--debug", is_flag=True,
help="enable debugging",
)
@click.argument("input_path")
@click.argument("output_path")
def write_tiles(
tile_width, tile_height, resolutions, max_workers, batch_size,
fill_color, nested, linear16to8, debug, input_path, output_path
):
setup_logging(debug)
with WriteTiles(
tile_width, tile_height, resolutions, max_workers,
batch_size, fill_color, nested, linear16to8,
input_path, output_path
) as wt:
wt.write_metadata()
wt.write_label_image()
wt.write_macro_image()
wt.write_pyramid()
@cli.command(name='write_metadata')
@click.option(
"--debug", is_flag=True,
help="enable debugging",
)
@click.argument('input_path')
@click.argument('output_file')
def write_metadata(debug, input_path, output_file):
setup_logging(debug)
with WriteTiles(
None, None, None, None,
None, None, None, input_path, None
) as wt:
wt.write_metadata_json(output_file)
def main():
cli()