HEX
Server: LiteSpeed
System: Linux houston.panomity.com 6.8.0-100-generic #100-Ubuntu SMP PREEMPT_DYNAMIC Tue Jan 13 16:40:06 UTC 2026 x86_64
User: nudepix (1011)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: //proc/self/root/workspace/embed_illustrations.py
#!/usr/bin/env python3
"""
Embed JG11 illustrations into teaching materials
"""

from docx import Document
from docx.shared import Inches, Pt
from pptx import Presentation
from pptx.util import Inches as PptxInches
import os

# Paths
BILDER_DIR = "/mnt/onedrive_write/FOS_Deutsch_Lehrplanvergleich_2026/06_Bilder/"
MATERIAL_DIR = "/mnt/onedrive_write/FOS_Deutsch_Lehrplanvergleich_2026/03_Jahrgang_11/"

# File mappings
tasks = [
    {
        "type": "docx",
        "doc": os.path.join(MATERIAL_DIR, "Arbeitsblätter/AB1_Social-Media-Phänomene.docx"),
        "image": os.path.join(BILDER_DIR, "JG11_Funktion1_Einstieg.png"),
        "description": "AB1: JG11_Funktion1_Einstieg.png"
    },
    {
        "type": "docx",
        "doc": os.path.join(MATERIAL_DIR, "Arbeitsblätter/AB3_Podcasts-moderne-Medienformate.docx"),
        "image": os.path.join(BILDER_DIR, "JG11_Funktion3_Analyse.png"),
        "description": "AB3: JG11_Funktion3_Analyse.png"
    },
    {
        "type": "pptx",
        "doc": os.path.join(MATERIAL_DIR, "Präsentationen/Arbeitsphasen_Jahrgang11_Social-Media.pptx"),
        "images": [
            os.path.join(BILDER_DIR, "JG11_Funktion2_Begriff.png"),
            os.path.join(BILDER_DIR, "JG11_Funktion4_Transfer.png")
        ],
        "description": "Präsentation: JG11_Funktion2_Begriff.png + JG11_Funktion4_Transfer.png"
    }
]

def add_image_to_docx(doc_path, image_path):
    """Add image to a DOCX file at the end of the document"""
    try:
        doc = Document(doc_path)
        
        # Add image at the end of the document
        # Add a paragraph break first
        doc.add_paragraph()
        
        # Add the image (6 inches wide to fit well on A4)
        doc.add_picture(image_path, width=Inches(6))
        
        # Save
        doc.save(doc_path)
        return True
    except Exception as e:
        print(f"Error adding image to {doc_path}: {e}")
        return False

def add_images_to_pptx(pptx_path, image_paths):
    """Add images to a PPTX file - create new slides for each image"""
    try:
        prs = Presentation(pptx_path)
        
        for image_path in image_paths:
            # Add a blank slide at the end
            blank_layout = prs.slide_layouts[6]  # Usually blank layout
            slide = prs.slides.add_slide(blank_layout)
            
            # Add image centered on slide (10 inches wide for full slide impact)
            # PowerPoint slides are typically 10" x 7.5" (4:3) or 13.33" x 7.5" (16:9)
            # We'll center the image
            img_width = PptxInches(9)
            img_left = PptxInches(0.5)
            img_top = PptxInches(1.5)
            
            slide.shapes.add_picture(image_path, img_left, img_top, width=img_width)
        
        # Save
        prs.save(pptx_path)
        return True
    except Exception as e:
        print(f"Error adding images to {pptx_path}: {e}")
        return False

# Process tasks
results = []

for task in tasks:
    print(f"\n{'='*60}")
    print(f"Processing: {task['description']}")
    print(f"{'='*60}")
    
    if task["type"] == "docx":
        success = add_image_to_docx(task["doc"], task["image"])
        if success:
            results.append(f"✅ {task['description']}")
        else:
            results.append(f"❌ {task['description']}")
    
    elif task["type"] == "pptx":
        success = add_images_to_pptx(task["doc"], task["images"])
        if success:
            results.append(f"✅ {task['description']}")
        else:
            results.append(f"❌ {task['description']}")

# Summary
print("\n" + "="*60)
print("ZUSAMMENFASSUNG")
print("="*60)
for result in results:
    print(result)

print("\nFertig!")