(docx_path, output_dir)
| 584 | |
| 585 | |
| 586 | def extract_images_from_docx(docx_path, output_dir): |
| 587 | doc = Document(docx_path) |
| 588 | count = 0 |
| 589 | for i, rel in enumerate(doc.part.rels): |
| 590 | if "image" in doc.part.rels[rel].target_ref: |
| 591 | image = doc.part.rels[rel].target_part.blob |
| 592 | image_path = os.path.join(output_dir, f'image_{count + 1}.png') |
| 593 | with open(image_path, "wb") as f: |
| 594 | f.write(image) |
| 595 | count += 1 |
| 596 | # print(f"Extracted {count} images from {docx_path}") |
| 597 | |
| 598 | |
| 599 | def extract_from_file(output_dir): |
nothing calls this directly
no outgoing calls
no test coverage detected