Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Read, create, merge, split, watermark, encrypt, OCR, and fill PDF files using Python and CLI tools
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
scripts/create_validation_image.py
1import json2import sys34from PIL import Image, ImageDraw56789def create_validation_image(page_number, fields_json_path, input_path, output_path):10with open(fields_json_path, 'r') as f:11data = json.load(f)1213img = Image.open(input_path)14draw = ImageDraw.Draw(img)15num_boxes = 01617for field in data["form_fields"]:18if field["page_number"] == page_number:19entry_box = field['entry_bounding_box']20label_box = field['label_bounding_box']21draw.rectangle(entry_box, outline='red', width=2)22draw.rectangle(label_box, outline='blue', width=2)23num_boxes += 22425img.save(output_path)26print(f"Created validation image at {output_path} with {num_boxes} bounding boxes")272829if __name__ == "__main__":30if len(sys.argv) != 5:31print("Usage: create_validation_image.py [page number] [fields.json file] [input image path] [output image path]")32sys.exit(1)33page_number = int(sys.argv[1])34fields_json_path = sys.argv[2]35input_image_path = sys.argv[3]36output_image_path = sys.argv[4]37create_validation_image(page_number, fields_json_path, input_image_path, output_image_path)38