Skip to content

Commit

Permalink
'order' and 'rotate' option
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Keim committed Jan 16, 2023
1 parent 75a3265 commit 7ae2a9e
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
Changelog
=========

Version 0.1.5
===========

- added 'order' option
- added 'rotate' option
- Basic tests passed (97% coverage | 204run | 0 missing | 4 excluded | 8 partial)

Version 0.1.4
===========

Expand Down
16 changes: 14 additions & 2 deletions src/kubi/kubi.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

IsWin = platform.system() == 'Windows'

__version__ = '0.1.4'
__version__ = '0.1.5'

__author__ = "Keim, Stefan"
__copyright__ = "Keim, Stefan"
Expand Down Expand Up @@ -94,7 +94,17 @@ def kubi(args):
pyvips.Image.bandjoin(x0+2,y0+1),
pyvips.Image.bandjoin(x0%4,y0+1),
]


if args.order:
tmp = idx.copy()
for i in range(0, 6):
idx[i] = tmp[args.order[i]]
tmp = None

if args.rotate:
for i in range(0, 6):
idx[i] = idx[i].rot(f'd{args.rotate[i]}')


if args.layout is None or args.layout in ("column","row"):
if args.inverse is not None:
Expand Down Expand Up @@ -275,6 +285,8 @@ def parse_args(args):
nohalo: edge sharpening resampler with halo reduction;
vsqbs: B-Splines with antialiasing smoothing
""")
parser.add_argument('--order', dest="order", metavar='<int>', nargs=6, type=int, help="tile order for +X, -X, +Y, -Y, +Z, -Z")
parser.add_argument('--rotate', dest="rotate", metavar='<int>', nargs=6, type=int, choices=[0, 90, 180, 270], help="tile rotation for +X, -X, +Y, -Y, +Z, -Z")
parser.add_argument('-f', '--facenames', metavar="<str>", nargs=6 ,help='suffixes for +X, -X, +Y, -Y, +Z, -Z (e.g. -f r l u d f b)')
parser.add_argument('-co', dest='co', metavar='<NAME=VALUE>*', action='append', help='create options (more info in the epilog)')
parser.add_argument('--io', dest='io', help='index file output', metavar='dstindex')
Expand Down
14 changes: 12 additions & 2 deletions tests/test_kubi.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,16 @@ def test_main_row_multi(capsys):
dst0 = pyvips.Image.new_from_file(dst_names[0])
assert dst0.width == 512 * 6 and dst0.height == 512

#def test_main_row_order_rotate(capsys):
# args = ['-l','row','--order', '0', '1', '5', '4', '2', '3', '--rotate', '270','90','180','0','0','180', '-s','512', path_in+'base*.tif', path_out+'basemap_row_order_rotate.png']
# print('\nargs: '+' '.join(args))
# main(args)
#
# dst_names = glob.glob(path_out+"*_row_order_rotate.png")
# assert len(dst_names) == 2
# dst0 = pyvips.Image.new_from_file(dst_names[0])
# assert dst0.width == 512 * 6 and dst0.height == 512

def test_main_crossL(capsys):
args = ['-l','crossL','-i','horizontal', path_in+'basemap.tif', path_out+'basemap_crossL.png']
print('\nargs: '+' '.join(args))
Expand Down Expand Up @@ -171,8 +181,8 @@ def test_main_tiled(capsys):
print('\nargs: '+' '.join(args))
main(args)

dst_names = glob.glob(path_out+"tiled/**/*", recursive=True)
assert len(dst_names) == 54
dst_names = glob.glob(path_out+"tiled/**/*.jpg", recursive=True)
assert len(dst_names) == 30



Expand Down

0 comments on commit 7ae2a9e

Please sign in to comment.