Sub topic 10
Preparing sizes and formats for each channel
A generated image is rarely the right shape for where it will run. Generators produce a few fixed sizes, while channels want specific aspect ratios, pixel dimensions, and file types. This chapter covers how to plan for that before you generate, how to crop and resize with a script, and how to choose file formats.
This chapter assumes you can read basic Python, know what resolution and aspect ratio mean, and have a generated hero image from the earlier chapters on prompts and iteration.
Why channel formats matter
A channel is a place where the image will appear: a feed post, a story, an ad unit, an email header, a landing page banner. Each one has its own shape and rules. If you ignore them, the platform will crop or compress your image for you, and it will not care where your subject sits.
Three properties matter:
- Aspect ratio is the width divided by the height, written as width:height. A 1080 × 1350 image is 4:5.
- Pixel dimensions are the exact width and height. Platforms usually recommend a size, and larger files are scaled down.
- File format and size decide how the image is compressed and how fast it loads.
Platform specifications change often. Treat the numbers in this chapter as common examples, and check each channel's current guidance before a campaign.
Common sizes by channel
The sizes below match the export script later in this chapter.
| Use | Pixels | Ratio | Notes |
|---|---|---|---|
| Square feed post | 1080 × 1080 | 1:1 | Works on most social feeds |
| Portrait feed post | 1080 × 1350 | 4:5 | Takes more screen space on phones |
| Link ad or link preview | 1200 × 628 | about 1.91:1 | Wide crop, often shown with a headline below |
| Story or vertical video cover | 1080 × 1920 | 9:16 | Top and bottom areas may be covered by interface elements |
| Email header | 600 to 1200 wide | varies | Keep the file small, since many people open email on mobile data |
| Website hero banner | 1600 to 2400 wide | wide | Often needs a mobile version as well |
Plan the crop before you generate
The most common mistake is generating a square image and then trying to force it into every shape. A wide crop of a square image removes the top and bottom. A tall crop removes the sides. If the subject or the headline space sits in the wrong place, the crop fails.
There are two ways to avoid this.
- Generate in the shape you need most. Most tools let you pick an aspect ratio. Choose the one for your main channel.
- Generate with a safe zone. Put the subject near the center and leave room around it, so that several crops still contain it. Mention this in the prompt, for example "subject centered with generous empty space on all sides".
If a channel needs a very different shape, generate a separate image for it. That often gives a better result than a heavy crop. Reference images and outpainting (extending the canvas) can also help, as described in the chapter on reference images and editing.
Check the source resolution
Resizing down is safe. Resizing up is not. If a generator gives you 1024 × 1024 and you need 1080 × 1920, the tool must stretch pixels, and the image will look soft. Cropping makes this worse because the crop discards pixels first.
For example, a 1024 × 1024 image cropped to 9:16 keeps a strip about 576 pixels wide and 1024 tall. Scaling that to 1080 × 1920 enlarges it by almost 1.9 times. For a small phone preview this may pass. For a large banner it will not.
When the source is too small, you have three options:
- Generate at a higher resolution if the tool offers it.
- Use an upscaler, a tool that adds detail while enlarging. Review the result closely, since upscalers can invent textures and alter faces or fine patterns.
- Choose a layout that needs less enlargement.
Exporting variants with a script
The script below takes one image and writes one file per channel size. ImageOps.fit crops to the target ratio and then resizes, with centering=(0.5, 0.5) meaning the crop is taken from the middle.
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 and place bottle_hero.png next to the script before you run it.
A center crop is a blunt tool. It does not know where your subject is. In the brief from the earlier chapter, the bottle sits on the right third of the frame. A center crop to a tall story shape keeps the middle strip and may cut the bottle in half. Always open every exported file and look at it.
You can move the crop with the centering argument. Values run from 0.0 to 1.0 on each axis. To keep a subject on the right, use centering=(0.75, 0.5). To favor the top of a tall crop, lower the second value.
Safe zones
A safe zone is the part of the image where important content will not be covered or cut. Stories are the usual case: the top and bottom edges often carry profile names, reply boxes, or buttons. Keep faces, products, and headlines away from those areas. Link ads may also be cropped differently in different placements, so a subject near the edge is a risk.
A practical habit is to design for the smallest safe area. Put the subject in the middle and leave the edges for background that can be trimmed.
Choosing a file format
| Format | Compression | Transparency | Best for | Watch out for |
|---|---|---|---|---|
| JPEG | Lossy | No | Photos and photo-like generated images | Visible blocks at low quality, repeated saving loses detail |
| PNG | Lossless | Yes | Graphics, images with text added, logos, working files | Large files for photos |
| WebP | Lossy or lossless | Yes | Web pages, where small files matter | Not accepted by every ad platform or email client |
| AVIF | Lossy or lossless | Yes | Web pages that need very small files | Support is still uneven outside browsers |
Some practical rules:
- Keep a lossless master, usually PNG, of every image you approve. Make channel files from the master, not from earlier exports.
- Use JPEG at quality 85 to 92 for photographic exports. Lower values save space but can show artifacts on smooth gradients such as skies.
- Use PNG when the image contains flat color, sharp edges, or added text. JPEG tends to blur text edges.
- Email clients vary widely, so JPEG and PNG are the safest choices there.
- Ad platforms often set a maximum file size, so check the limit and reduce quality if you exceed it.
Color and metadata
Export in the sRGB color profile. It is what browsers and most platforms assume. Pillow's convert("RGB") gives you RGB pixel data, but it does not convert profiles, so an image with an embedded wide-gamut profile can look dull or shifted after the profile is dropped. If colors matter, such as brand blues, compare the exported file with the master.
Some generators write information into files, such as the tool used or provenance data. Keep this in mind for disclosure rules, which a later chapter covers. Do not strip it without checking your policy and the tool's terms.
Naming and organizing exports
Consistent names make files easier to find and hand off. The script above uses the source name plus the channel, such as bottle_hero_story.jpg. For a campaign, add a version number and a date so that you can tell which file went live.
Common errors
- Generating once, cropping everywhere. The subject ends up cut in some formats. Plan the safe zone or generate separate versions.
- Upscaling a small crop. The result is soft or has invented detail. Start from a larger source.
- Saving JPEG over JPEG. Each save loses detail. Always export from the master.
- Text baked into a crop. If text was added before cropping, a crop can cut letters. Crop first, then add text, as the chapter on text and logos recommends.
- Ignoring file size. A 6 MB hero image slows a landing page and can hurt results.
Exercise
A generated image is 1024 × 1024. You need a 1200 × 628 link ad and a 1080 × 1920 story. For each, state what you lose by cropping, and say what you would do to keep the subject safe.
Show answer
The link ad ratio is about 1.91:1, so a crop keeps a strip 1024 pixels wide and about 536 tall, which discards roughly half the height. The story ratio is 9:16, so the crop keeps a strip about 576 wide and 1024 tall, which discards about 44 percent of the width. In both cases, the subject must sit where the crop keeps it. For the link ad, center the subject vertically or move the crop with the centering argument. For the story, keep the subject near the middle, away from the top and bottom interface areas, and keep in mind that scaling 576 pixels up to 1080 is an enlargement of almost 1.9 times, so check sharpness. If either result is poor, generate a new image in the target ratio.
Exercise
Why should you keep a lossless PNG master and export every channel file from it, instead of resizing the previous JPEG?
Show answer
JPEG is lossy, so each save discards some detail and can add artifacts. Exporting from the PNG master means every channel file goes through lossy compression only once. It also lets you regenerate files later when a platform changes its size requirements without quality loss from earlier exports.
Exercise
Modify the export script so the portrait feed variant keeps a subject that sits on the right third of the frame. What change would you make, and what would you check afterwards?
Show answer
Pass a different centering value for that variant, for example centering=(0.75, 0.5), so the crop window shifts toward the right side of the source. Because the 1080 × 1350 target is 4:5 and the source is square, the crop only has horizontal room to move, so the first number matters and the second has little effect. Afterwards, open the exported file at full size and confirm the subject is complete, the headline space is still where the brief requires it, and no edge is cut.