This project combines DALL-E Mini for text-to-image generation with a novel expansion technique (E-DALL-E) that allows creating images with different aspect ratios. It also provides standalone tools for expanding existing images to various aspect ratios without requiring AI generation.
The system consists of these integrated components:
- DALL-E Mini - Generates square (1:1) images from text prompts
- E-DALL-E - Expands the generated images to different aspect ratios (e.g., 16:9) using VQGAN+CLIP
- Image Expander (Online) - A tool to download and expand online images to different aspect ratios
- Image Expander (Local) - A tool to expand local image files to different aspect ratios
- Results Viewer - A gallery tool to view all expanded images created with the system
Install the required dependencies:
pip install -r requirements.txtRun the main script with a text prompt to generate and expand images:
python edalle.py --prompt "a painting of rolling farmland" --aspect_ratio 1.78 --num_images 4--prompt: Text prompt for image generation (default: "a painting of rolling farmland")--num_images: Number of images to generate (default: 4)--aspect_ratio: Target aspect ratio for expansion (width/height, default: 16/9)--iterations: Number of optimization iterations for expansion (default: 100)--model_type: DALL-E model size ("mini", "mega", or "mega-full", default: "mega")
Download and expand any online image to your desired aspect ratio:
python download_expand.py --url "https://example.com/image.jpg" --aspect 16:9 --orientation landscape--url: URL of the image to download (defaults to a sample Van Gogh image)--aspect: Target aspect ratio, can be in format "16:9" or decimal "1.78" (default: "16:9")--orientation: Orientation of the expansion, "landscape" or "portrait" (default: "landscape")--output: Path to save the expanded image (default: "expanded_download.png")
Expand any local image file to your desired aspect ratio:
python local_expand.py input_image.jpg --aspect 21:9 --orientation landscape- First argument: Path to the input image file (required)
--aspect: Target aspect ratio, can be in format "16:9" or decimal "1.78" (default: "16:9")--orientation: Orientation of the expansion, "landscape" or "portrait" (default: "landscape")--output: Path to save the expanded image (default: "expanded_" + input filename)
Create visual galleries of all expanded images:
python view_results.pyThis script will:
- Scan the current directory for expanded and comparison images
- Generate two gallery images:
comparison_gallery.png: Shows side-by-side comparisons of original and expanded imagesexpanded_gallery.png: Shows all expanded images with their dimensions and aspect ratios
- The system first generates square (1:1) images using DALL-E Mini based on your text prompt
- It then expands one of these images to your desired aspect ratio in two steps:
- Initially filling in the sides with repeated edge pixels
- Using VQGAN+CLIP to generate new content on the sides that matches the style and content of the original image and follows the text prompt
The edge pixel expansion process:
- Creates a canvas with the target dimensions
- Places the original image in the center
- Fills the empty regions by repeating and blending edge pixels from the original image
- Applies a gradient blend to ensure smooth transitions
The system supports any aspect ratio, but here are some common ones:
| Aspect Ratio | Common Use Cases |
|---|---|
| 1:1 (1.0) | Standard square images, Instagram |
| 4:3 (1.33) | Traditional TV/monitors |
| 16:9 (1.78) | HD video, modern displays |
| 21:9 (2.33) | Ultrawide monitors, cinematic |
| 2.39:1 | Anamorphic widescreen cinema |
| 9:16 (0.56) | Vertical video, mobile devices |
The system generates various output files:
- Original images:
original_*.png - Expanded images:
expanded_*.png - Comparison images:
comparison_*.png - Gallery images:
expanded_gallery.pngandcomparison_gallery.png
You can specify custom aspect ratios in two formats:
- Ratio format:
--aspect 4:3 - Decimal format:
--aspect 1.33
You can chain these tools together for creative workflows:
- Generate images with
edalle.py - Expand existing images with
local_expand.py - View all results with
view_results.py
This project is licensed under the MIT License.
You are free to use, modify, and distribute this software in accordance with the terms of the license.
This implementation is based on:
- DALL-E Mini by Boris Dayma and Pedro Cuenca
- VQGAN+CLIP for image expansion
- The original E-DALL-E concept by Robert A. Gonsalves




