Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def compose_contact_sheet(
media_info,
frames,
args):
"""Creates a video contact sheet with the media information in a header
and the selected frames arranged on a mxn grid with optional timestamps
"""
desired_size = grid_desired_size(
args.grid,
media_info,
width=args.vcs_width,
horizontal_margin=args.grid_horizontal_spacing)
width = args.grid.x * (desired_size[0] + args.grid_horizontal_spacing) - args.grid_horizontal_spacing
height = args.grid.y * (desired_size[1] + args.grid_vertical_spacing) - args.grid_vertical_spacing
header_font = load_font(args, args.metadata_font, args.metadata_font_size, Config.metadata_font)
timestamp_font = load_font(args, args.timestamp_font, args.timestamp_font_size, Config.timestamp_font)
header_lines = prepare_metadata_text_lines(
media_info,
header_font,
args.metadata_horizontal_margin,
width,
template_path=args.metadata_template_path)
line_spacing_coefficient = 1.2
header_line_height = int(args.metadata_font_size * line_spacing_coefficient)
header_height = 2 * args.metadata_margin + len(header_lines) * header_line_height
if args.metadata_position == "hidden":
header_height = 0
parser.add_argument(
"-t", "--show-timestamp",
action="store_true",
help="display timestamp for each frame",
dest="show_timestamp")
parser.add_argument(
"--metadata-font-size",
help="size of the font used for metadata",
dest="metadata_font_size",
type=int,
default=Config.metadata_font_size)
parser.add_argument(
"--metadata-font",
help="TTF font used for metadata",
dest="metadata_font",
default=Config.metadata_font)
parser.add_argument(
"--timestamp-font-size",
help="size of the font used for timestamps",
dest="timestamp_font_size",
type=int,
default=Config.timestamp_font_size)
parser.add_argument(
"--timestamp-font",
help="TTF font used for timestamps",
dest="timestamp_font",
default=Config.timestamp_font)
parser.add_argument(
"--metadata-position",
help="Position of the metadata header. Must be one of ['top', 'bottom', 'hidden']",
dest="metadata_position",
type=metadata_position_type,