Convert a single image into an editable PowerPoint slide.
This is a general-purpose image-to-editable-PPTX tool, not a screenshot wrapper. It rebuilds the slide as editable objects:
- background shape
- card / white panel shapes
- cropped image block
- editable text boxes from source layout JSON or OCR
- a
layout.jsonsidecar for debugging and future tuning
- Python 3.9+
Pillowpython-pptxrapidocr-onnxruntimefor the default OCR path- macOS Swift/Vision is optional and only used as a fallback backend
Install Python dependencies:
python3 -m pip install -r requirements.txtpython3 image_to_editable_pptx.py /path/to/input.jpg -o /path/to/output.pptxThis command works on a standalone image. If you also have a structured layout JSON from another design/export system, you can pass it explicitly for a higher-fidelity reconstruction:
python3 image_to_editable_pptx.py /path/to/input.jpg \
--source-layout /path/to/layout.json \
-o /path/to/output.pptxWhen no source layout JSON is provided, the tool falls back to image analysis and writes a sidecar layout file:
output.layout.json
- Reads the source layout JSON.
- Converts JSON
shapeelements to editable PowerPoint shapes. - Decodes JSON
imageelements into PowerPoint picture objects. - Converts JSON
textelements into editable text boxes while preserving text, font size, color, alignment, bold, and italic when those styles exist.
- Samples the image corners to infer the slide background color.
- Detects the dominant content card by finding pixels that differ from the background.
- Finds the bright header panel inside the card.
- Treats the lower card area as the hero image block and crops it into an editable picture object.
- Runs OCR with
RapidOCRas the primary backend. - Falls back to a native macOS Vision helper if
RapidOCRis unavailable. - Re-runs OCR on focused regions such as the white panel to improve small-text stability.
- Repairs common OCR issues such as collapsed CamelCase spaces.
- Infers text color, approximate font size, font family, alignment, boldness, and multiline grouping from the original image.
- Uses an automatic render strategy:
- if card/panel/image-block structure is reliable, rebuild with editable shapes
- otherwise preserve the full image as slide base to keep layout stable
- Adds OCR text boxes as editable layers using
python-pptx.
Compared with the previous version:
- OCR no longer depends on a single Swift script path.
- Default OCR is more stable on real images because it uses a dedicated OCR model backend.
- Text boxes now preserve more style information in image-only mode.
- Source-layout mode also keeps
font-weightandfont-stylewhen present. - The generated
layout.jsonrecords the OCR backend that produced the result.
This project is intentionally generic, but the current heuristics are tuned for clean title slides and cover pages. It is designed to be extensible, not magically perfect for arbitrary complex posters.
Good fits:
- minimal cover pages
- title cards
- image + text hero layouts
- clean business slides
Poor fits:
- dense infographics
- highly decorative posters
- screenshots with many tiny UI labels
- layouts requiring exact font identification from pixels alone
If you clone this repository locally and run it with a single image:
- it will generate a
.pptx - that
.pptxwill contain editable PowerPoint objects, not just one flat screenshot - the output quality depends on layout complexity
- simple business cover slides should now be materially more stable than the previous OCR-first draft
For complex designs, treat the generated PPTX as a structured starting point, not a perfect reproduction.