## Lays out the PNGs in a directory as contact sheets of four, in name order, left to ## right then top to bottom, for reviewing a whole capture pass (H6). It prints which ## captures each sheet holds; open a capture on its own to judge detail. ## tools/godot.sh --script res://tools/contact_sheet.gd -- --dir=res://captures/qa --out=res://captures/qa/sheets extends SceneTree const CELL: Vector2i = Vector2i(960, 540) func _init() -> void: var dir: String = "res://captures/qa" var out: String = dir + "/sheets" for arg: String in OS.get_cmdline_user_args(): if arg.begins_with("--dir="): dir = arg.substr(6) elif arg.begins_with("--out="): out = arg.substr(6) DirAccess.make_dir_recursive_absolute(ProjectSettings.globalize_path(out)) var names: Array[String] = [] for name: String in DirAccess.get_files_at(dir): if name.ends_with(".png") and not name.begins_with("hud_2160"): names.append(name) names.sort() var sheets: int = 0 for first: int in range(0, names.size(), 4): var sheet: Image = Image.create(CELL.x * 2, CELL.y * 2, false, Image.FORMAT_RGB8) sheet.fill(Color.BLACK) for index: int in range(first, mini(first + 4, names.size())): var image: Image = Image.load_from_file(ProjectSettings.globalize_path(dir.path_join(names[index]))) if image == null: push_error("contact sheet: can't read %s" % names[index]) quit(1) return image.convert(Image.FORMAT_RGB8) image.resize(CELL.x, CELL.y, Image.INTERPOLATE_BILINEAR) var slot: int = index - first sheet.blit_rect(image, Rect2i(Vector2i.ZERO, CELL), Vector2i(slot % 2 * CELL.x, slot / 2 * CELL.y)) var path: String = out.path_join("sheet_%02d.png" % sheets) sheet.save_png(ProjectSettings.globalize_path(path)) var listed: PackedStringArray = PackedStringArray(names.slice(first, first + 4)) print("%s: %s" % [path, ", ".join(listed)]) sheets += 1 print("contact sheets: %d from %d captures" % [sheets, names.size()]) quit(0)