🚧 This is a WIP! 🚧
This script takes input images and pastes them onto a new image with a white background. The new image's width will be 2160px by default (configurable via a script argument) and its height will be dependent on the format provided.
Example (images have been scaled down for demonstration purposes):
- Install the Requirements below.
- Clone this repo or download the script itself.
- (Optional but recommended) Create a symlink for convenience:
➜ cd /usr/local/bin
➜ ln -s path/to/white_backgroundify.py white_backgroundify
Given a folder some/folder/with/images with the following contents:
my_image_1.jpg
my_image_2.jpg
my_image_3.jpg
Use white_backgroundify.py like this:
➜ ./white_backgroundify.py --format=4x5 --width=1000 some/folder/with/images/*.jpg
Created some/folder/with/images/white_bg/4x5/my_image_1_white_bg.jpg
Created some/folder/with/images/white_bg/4x5/my_image_2_white_bg.jpg
Created some/folder/with/images/white_bg/4x5/my_image_3_white_bg.jpg
--help: Shows a help doc.--format(Required): The desired crop of the output file (e.g.2x3,4x5,1x1, etc.)--width: The desired width of the output file.
- The output path of each image will be
so it's more convenient to use on a single folder with a wildcard path (e.g.
<input image's folder>/white_bg/<format>/<input image name>_white_bg.<input image extension>*.jpg) instead of individual images with separate paths. This is still possible, but you may end up with multiplewhite_bg/folders if the provided images aren't in the same folder. - This has only been tested with JPGs.
- This hasn't been tested much.
- Python 3.7.5
- Pillow 8.3.1
Use this if you don't want to faff around with a photo editor's automate/batch function.
- Make more options configurable through command line arguments:
- Image quality
- Margin
- Make crop formats adaptable (e.g. make 4x5 work with 5x4) – ideal for print

