From 1560357e9f73509fe086596710320dd8b9e20a91 Mon Sep 17 00:00:00 2001 From: Andreas Demmelbauer Date: Thu, 18 Nov 2021 19:01:26 +0100 Subject: [PATCH] add mask option --- convert-svg-to-geotiff.py | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/convert-svg-to-geotiff.py b/convert-svg-to-geotiff.py index 9469c8d..2a67bce 100644 --- a/convert-svg-to-geotiff.py +++ b/convert-svg-to-geotiff.py @@ -12,15 +12,24 @@ import rasterio arg_parser = argparse.ArgumentParser(description='Export SVG composition of FLIR images as TIFF with thermo layer') -arg_parser.add_argument('Input', - metavar='input_svg', - type=str, - help='Path to the input SVG file cotaining xlinks to FLIR images') - -arg_parser.add_argument('Output', - metavar='output_tiff', - type=str, - help='Output filename') +arg_parser.add_argument( + 'Input', + metavar='input_svg', + type=str, + help='Path to the input SVG file cotaining xlinks to FLIR images') + +arg_parser.add_argument( + 'Output', + metavar='output_tiff', + type=str, + help='Output filename' +) + +arg_parser.add_argument( + '--use-mask', action='store_true', + help="Using soft edges for smooth transitions between tiles", + dest='use_mask' +) args = arg_parser.parse_args() @@ -89,15 +98,20 @@ def make_thermalpng_svg(): root = tree.getroot() # print(ET.tostring(root)) # tile_rows = root.xpath('//image', namespaces={'n': "http://www.w3.org/2000/svg"}) - # print(dir(root)) tile_elements = root.xpath('//*[@class="thermal_image"]') linkattrib ='{http://www.w3.org/1999/xlink}href' for tile in tile_elements: new_file_path = os.path.join(THERMALPNG_DIR, tile.attrib[linkattrib] + '.thermal.png') tile.attrib[linkattrib] = new_file_path # Post Production - # tile.attrib["mask"] = 'url(#tilefademask)' - # tile.attrib["style"] = 'opacity:.7' + if args.use_mask: + # mask_rect = root.xpath('//*[@id="mask_rect"]') + # mask_rect_filter = root.xpath('//*[@id="mask_rect_filter"]') + # print(mask_rect) + # print(mask_rect_filter) + for tile in tile_elements: + tile.attrib["mask"] = 'url(#tilefademask)' + # tile.attrib["style"] = 'opacity:.7' # newxml = ET.tostring(tree, encoding="unicode")