afb7bf6a5a
Non-technical users asking for Word docs, spreadsheets, or PDF work had no bundled skill coverage — docx/xlsx creation required discovering and installing hub skills, and PDF manipulation had no skill at all beyond OCR extraction and nano-pdf edits. - skills/productivity/docx: create (docx-js), edit (unzip -> XML -> zip), tracked changes, comments, validation. Adapted from anthropics/skills. - skills/productivity/xlsx: openpyxl creation/editing, mandatory LibreOffice recalc gate, formula-compatibility rules, financial-model conventions. Points at optional excel-author for finance-grade work. - skills/productivity/pdf: merge/split/rotate/watermark/encrypt, form filling (AcroForm + flat overlay scripts), text/table extraction, reportlab creation, forms.md + reference.md companions. - skills/productivity/powerpoint: synced to current upstream pptx skill — richer pptxgenjs corruption footguns, template workflow, validate.py + validators + thumbnail.py, font-substitution QA guidance; drops the stale pack.py/editing.md/pptxgenjs.md workflow files. - Cross-linked ocr-and-documents, nano-pdf, excel-author via related_skills so each office skill routes to its siblings. - deliverable-mode docs mention the new skills; regenerated per-skill docs pages, catalogs, and sidebar. - tests/skills/test_office_document_skills.py: frontmatter contracts, referenced-script existence, schema-map integrity, cross-link resolution, script compilation. E2E validated: docx create->render->edit->validate, xlsx recalc (SUM + _xlfn.TEXTJOIN evaluate correctly), pdf create->merge->extract, pptx generate->validate->thumbnail.
38 lines
1.2 KiB
Python
38 lines
1.2 KiB
Python
import json
|
|
import sys
|
|
|
|
from PIL import Image, ImageDraw
|
|
|
|
|
|
|
|
|
|
def create_validation_image(page_number, fields_json_path, input_path, output_path):
|
|
with open(fields_json_path, 'r') as f:
|
|
data = json.load(f)
|
|
|
|
img = Image.open(input_path)
|
|
draw = ImageDraw.Draw(img)
|
|
num_boxes = 0
|
|
|
|
for field in data["form_fields"]:
|
|
if field["page_number"] == page_number:
|
|
entry_box = field['entry_bounding_box']
|
|
label_box = field['label_bounding_box']
|
|
draw.rectangle(entry_box, outline='red', width=2)
|
|
draw.rectangle(label_box, outline='blue', width=2)
|
|
num_boxes += 2
|
|
|
|
img.save(output_path)
|
|
print(f"Created validation image at {output_path} with {num_boxes} bounding boxes")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
if len(sys.argv) != 5:
|
|
print("Usage: create_validation_image.py [page number] [fields.json file] [input image path] [output image path]")
|
|
sys.exit(1)
|
|
page_number = int(sys.argv[1])
|
|
fields_json_path = sys.argv[2]
|
|
input_image_path = sys.argv[3]
|
|
output_image_path = sys.argv[4]
|
|
create_validation_image(page_number, fields_json_path, input_image_path, output_image_path)
|