Image Expander is a GenAI tool designed to expand images in any direction (left, right, top, bottom). It allows you to upload a photo and extend its boundaries while maintaining visual coherence with the original content.
Image Expander utilizes generative AI to create authentic-looking extensions to your images. It's particularly useful for:
- Content creation: Expand images to fit different aspect ratios
- Photography: Extend the canvas of your photos
- Design: Adapt existing images to new layout requirements
The following instructions suppose you have already installed a recent version of Python. To use any PiktID API, an access token is required.
Step 0 - Register here. 10 credits are given for free to all new users.
Step 1 - Clone the Image Expander repository
# Installation commands
$ git clone https://github.com/piktid/expand.git
$ cd expandStep 2 - Export the email and password as environmental variables
$ export PIKTID_EMAIL={Your email here}
$ export PIKTID_PASSWORD={Your password here}or the authenticaton tokens - get them in https://studio.piktid.com/profile -> Tokens & Sessions
$ export ACCESS_TOKEN={Your access token}
$ export REFRESH_TOKEN={Your refresh token}Step 3 - Run the main function with a URL or local file path of the image and specify expansion parameters
# Using a URL with bottom expansion
$ python3 main.py --input_url 'your-url' --bottom 960 --seed 0
# Using a local file path with bottom expansion
$ python3 main.py --input_filepath '/path/to/your/image.jpg' --bottom 960 --seed 0You can customize the expansion parameters with the following options:
# Generate an expansion with specific parameters
$ python3 main.py --input_filepath '/path/to/your/image.jpg' --left 0 --right 0 --top 0 --bottom 960 --seed 0 --var_strength 1 --prompt_strength 1 --prompt 'beach scene' --output_filepath '/path/to/save/output.jpg'- input_url: URL of the image to process
- input_filepath: Local path to the image file
- output_filepath: Where to save the generated image
- left: Left expansion in pixels (default: 0)
- right: Right expansion in pixels (default: 0)
- top: Top expansion in pixels (default: 0)
- bottom: Bottom expansion in pixels (default: 0)
- prompt: Optional textual guidance for the expansion (default: empty)
- prompt_strength: How much the expansion follows the prompt (default: None)
- var_strength: Variation strength for the generation (default: None)
- seed: Random seed for reproducible results (default: random)
- prompt_enhance: Enable prompt enhancement (flag)
After uploading images, you'll receive a unique ID for the input image. You can use this ID to resume or create new expansions without uploading the image again:
$ python3 main.py --id_image "ySHnKElbKC4RIx7h" --left 0 --right 0 --top 0 --bottom 1000 --seed 1 --var_strength 1This is particularly useful when:
- Working with the same image multiple times
- Creating variations of previous expansions
- Saving bandwidth by avoiding re-uploads