Sub topic 10
Preparing sizes and formats for each channel
This chapter assumes you can write a prompt and have a generated image you like. It also assumes you know what aspect ratio, resolution, and file format mean. Here you turn one approved image into the files each channel needs.
Why one image is not enough
Each channel crops and displays images differently. A square feed post, a 4:5 portrait, a link ad, and a vertical story all have different shapes. If you upload one shape everywhere, the platform will crop it for you, and it may cut off your subject or your headline space.
Plan for this early. Generate the image with the widest safe area in mind, then export one variant per channel.
Common sizes
Check each platform's current specifications before you export, because they change. These sizes are common starting points.
| Variant | Size (pixels) | Ratio | Typical use |
|---|---|---|---|
| square_feed | 1080 x 1080 | 1:1 | Social feed post |
| portrait_feed | 1080 x 1350 | 4:5 | Instagram feed, more screen space |
| link_ad | 1200 x 628 | about 1.91:1 | Link ads and shared links |
| story | 1080 x 1920 | 9:16 | Stories and short vertical formats |
Choosing a file format
- JPEG suits photographic images. It gives small files, but it is lossy, so repeated saves lower quality.
- PNG is lossless and supports transparency. Use it for graphics with sharp edges or when you need a transparent background. Files are larger.
- WebP gives smaller files than JPEG at similar quality. It works well on landing pages, but check that your email client and ad platform accept it.
For most social and ad uploads, a high-quality JPEG is a safe default. Keep your original generated file, usually PNG, as the master and export from it.
Exporting variants with Pillow
The script below crops and resizes one image into every size in the table. ImageOps.fit scales the image to cover the target shape, then crops the overflow.
from pathlib import Path
from PIL import Image, ImageOps
SIZES = {
"square_feed": (1080, 1080),
"portrait_feed": (1080, 1350),
"link_ad": (1200, 628),
"story": (1080, 1920),
}
def export_variants(source_path, out_dir):
source = Path(source_path)
out = Path(out_dir)
out.mkdir(parents=True, exist_ok=True)
with Image.open(source) as img:
img = img.convert("RGB")
for name, size in SIZES.items():
variant = ImageOps.fit(img, size, method=Image.Resampling.LANCZOS, centering=(0.5, 0.5))
variant.save(out / f"{source.stem}_{name}.jpg", quality=90)
export_variants("bottle_hero.png", "exports")Install Pillow with pip install Pillow. The script expects bottle_hero.png in the current folder and writes four JPEG files to exports.
Common errors
A center crop cuts equally from both sides. If your subject sits on the right third, as in the bottle example, a wide crop can remove it. Open every exported file and check it.
Other frequent problems:
- Upscaling a small image. Stretching a 1024 pixel image to 1920 pixels high looks soft. Generate at the highest resolution your tool offers, or use an upscaler first.
- Ignoring safe zones. Stories and feeds overlay buttons and captions. Keep important content away from the top and bottom edges.
- Losing headline space. If you plan to add text later, confirm the empty area survives each crop.
How the workflow fits together
Exercise
Your bottle sits on the right third of a 1:1 master image. You export the 1200x628 link ad with the default center crop and the bottle is partly cut off. Name two ways to fix this.
Show answer
Change the centering so the crop favors the right side, for example centering=(0.8, 0.5) in ImageOps.fit. Alternatively, regenerate or edit the image with more background around the bottle (outpainting) so a wide crop keeps the whole subject. Either way, reopen the exported file to confirm the fix.