#!/usr/bin/env python3 """ Fix PPTX: update diagram images on slides 16 (A9) and 20 (B5), and fix Gemini model name on slide 12. """ from pptx import Presentation from pptx.util import Emu from PIL import Image import os PPTX_PATH = '/Users/maciejpi/Documents/INPI-WEWNETRZNE/NORDA-Business/NORDA_Prezentacja_Rada_2026-02-13.pptx' DIAGRAMS_DIR = '/Users/maciejpi/claude/projects/active/nordabiz/docs/architecture/diagrams' SLIDE_W = 9144000 SLIDE_H = 5143500 def replace_image_on_slide(slide, img_path): """Remove old images and add new one, keeping text shapes.""" # Remove old image shapes shapes_to_remove = [] for shape in slide.shapes: if shape.shape_type == 13: # MSO_SHAPE_TYPE.PICTURE shapes_to_remove.append(shape) for shape in shapes_to_remove: sp = shape._element sp.getparent().remove(sp) # Add new image top_margin = Emu(800000) bottom_margin = Emu(100000) side_margin = Emu(150000) avail_w = SLIDE_W - 2 * side_margin avail_h = SLIDE_H - top_margin - bottom_margin with Image.open(img_path) as img: img_w, img_h = img.size scale_w = avail_w / img_w scale_h = avail_h / img_h scale = min(scale_w, scale_h) final_w = int(img_w * scale) final_h = int(img_h * scale) left = side_margin + (avail_w - final_w) // 2 top = top_margin + (avail_h - final_h) // 2 slide.shapes.add_picture(img_path, Emu(left), Emu(top), Emu(final_w), Emu(final_h)) def fix_gemini_text(slide): """Fix Gemini model reference on slide.""" for shape in slide.shapes: if shape.has_text_frame: for para in shape.text_frame.paragraphs: for run in para.runs: if 'Gemini Free + Tier 1' in run.text: old = run.text run.text = run.text.replace( 'Gemini Free + Tier 1', 'Gemini 3 Flash + Gemini 3 Pro (paid tier, thinking mode)' ) print(f' Fixed: "{old[:80]}" → "{run.text[:80]}"') def main(): prs = Presentation(PPTX_PATH) # Fix slide 12: Gemini model name print('Fixing slide 12 (Gemini model name)...') fix_gemini_text(prs.slides[11]) # Update slide 16 (A9 - Detailed IT Architecture) print('Updating slide 16 (A9 - IT Architecture)...') img_a9 = os.path.join(DIAGRAMS_DIR, 'a9-detailed-it-architecture.png') replace_image_on_slide(prs.slides[15], img_a9) # Update slide 20 (B5 - AI Capabilities) print('Updating slide 20 (B5 - AI Capabilities)...') img_b5 = os.path.join(DIAGRAMS_DIR, 'b5-ai-capabilities.png') replace_image_on_slide(prs.slides[19], img_b5) prs.save(PPTX_PATH) print(f'\nSaved: {PPTX_PATH}') if __name__ == '__main__': main()