Inspiration
Creating on-the-fly images for social media marketing often involves repetitive, manual design work. We wanted a declarative way—using JSON—to define layouts, text, and graphics so that developers could automate the generation of Instagram posts, banners, and other assets without touching a design tool .
What it does
the image_template package provides:
- JSON-based DSL for defining image compositions (text, shapes, images).
- Rendering engine in Python that uses Pillow to produce high-resolution outputs.
- CLI tool for batch processing or single-template rendering.
- Caching of fonts and external assets for performance.
- Extensible component registry, so you can plug in your own shapes or behaviors (github.com).
How we built it
- Language & Libraries: Python 3.8+, Pillow for image ops, Pydantic (or built-in validation) for JSON schema enforcement, Click for the CLI.
- Architecture: A
TemplateEnginecore loads a JSON template, resolves variables, and dispatches each component (text, image, rectangle, etc.) to a registry of renderer classes. - Packaging: Standard Python package layout with
setup.py/pyproject.toml,requirements.txt, and entry-points fordolze-templatesCLI. - Examples & Docs: Ship ready-to-use templates under
examples/, plusshapes.mdfor built-in vector definitions (github.com).
Challenges we ran into
- Text wrapping & alignment: Measuring and fitting variable-length copy into fixed regions without overflow.
- Font management: Loading, caching, and fallback of custom fonts across different OS environments.
- Performance: Balancing high-resolution output with acceptable render times and memory usage.
- Extensibility: Designing a component API flexible enough for custom shapes or behaviors, yet simple for end users to extend.
Accomplishments that we’re proud of
- Delivered a fully-featured JSON DSL that non-designers can use to create professional assets.
- Built a robust CLI supporting single and recursive directory rendering.
- Achieved high test coverage across components, ensuring reliability under diverse inputs.
- Established a plugin/hook system so users can inject pre- and post-render logic (github.com).
What we learned
- Deep insights into Pillow’s text metrics and performance characteristics.
- Best practices in JSON schema design for user-friendly, self-documenting templates.
- Techniques for asset caching to speed up repeated renderings.
- How to structure a plugin architecture in Python for maximum flexibility.
What’s next for Instagram post generator
- Instagram Story & Reel templates with aspect-ratio presets and story stickers.
- Animated outputs (GIFs/MP4s) for motion posts.
- Integration with Instagram’s Graph API for direct upload and scheduling.
- A web UI/dashboard for non-technical users to select templates, edit copy, and preview assets.
- AI-powered copy suggestions and image recommendations to streamline content creation.
Log in or sign up for Devpost to join the conversation.