Browse Source

add mask option

master
Andreas Demmelbauer 3 years ago
parent
commit
1560357e9f
1 changed files with 26 additions and 12 deletions
  1. +26
    -12
      convert-svg-to-geotiff.py

+ 26
- 12
convert-svg-to-geotiff.py View File

@@ -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")


Loading…
Cancel
Save