# Last edited on 2025-11-06 21:23:32 by stolfi created = "created on " + str(datetime.now(tz = timezone.utc)) + "html_report_funcs.html_subpage_link " imgfile = f"{clip_dir}/annotated.png" # Image file. titfile = f"{clip_dir}/title.txt" # File with title of figure. legfile = f"{clip_dir}/legend.txt" # File with plain text caption. disfile = f"{clip_dir}/discussion.txt" # File with plain text discussion. # Obtain the figure's dimensions: imgsize = h.get_image_size(imgfile) title = h.get_text_from_file(titfile) title = h.protect_html(title) title = h.simple_markup(title) if thumb: thumb_width = 80*st['text_width']/100 else: thumb_width = 0 assert link_text != None, "must specify a link text" link_to_sub = h.make_link(st, subfile, link_text, thumb_width, imgfile) # Create the subsidiary page in memory: st_sub = h.new_doc(title, "#eeffdd", 800) caption = h.get_text_from_file(legfile) caption = h.protect_html(caption) caption = h.simple_markup(caption) caption = h.make_parags(caption, align = "left", width = "80%") imgfile_sub = f"annotated.png" # Name of image file rel to subpage. imgtag_sub = f"" h.figure(st_sub, imgtag_sub, caption, centered = True) discussion = h.get_text_from_file(legfile) if discussion != "": discussion = h.protect_html(discussion) discussion = h.simple_markup(discussion) discussion = h.make_parags(discussion) h.section(st_sub, 2, "Discussion") h.parags(st_sub, discussion) # Write out the subpage: wr_sub = open(subfile, "w") h.output_doc(st_sub, wr_sub, 0, created) wr_sub.close() # Scale each spectral component to standard deviation 1.0, # to give it equal chances of contributing to the result: # sys.stderr.error(f"scaling band images to unit deviation ...\n") # C = normalize_band_intensities_to_unit_std(C) # tfile = f"/tmp/{os.getpid()}-read_mask_image.pnm" # bash(f"convert {fname} -set colorspace LinearGray -colorspace LinearGray {tfile}") # M = read_pnm_image(tfile, 0, 0)