Resize an image for a sharper, lighter page
Set a width that fits the page, preserve the aspect ratio, and inspect the downloaded image.
Measure the width the destination needs, then resize each original by width and calculate its height from its own aspect ratio before exporting and opening the saved image. In the batch test, a width of 600 pixels produced a 600 by 400 cover and a 600 by 450 reference card, while forcing the cover to 600 by 250 visibly distorted its proportions. Compare the actual download’s pixel dimensions, byte size, and the readability of details before reusing those settings on the rest of your images.
What to look for
Use this guide when images are visually too heavy for a page, look soft after resizing, or stretch when placed into a fixed box. A batch can share a width and still contain differently shaped images. You may need separate heights even when every asset is intended for one layout. A preview that looks small on screen can also represent a large file, so inspect the actual dimensions and byte count separately.
Start with the relationship between the page and the source. A precise crop, a whole image reduced proportionally, and a smaller encoded copy are different delivery tasks. Identify which one your destination asks for before changing the inputs.

Why it happens
Width and height describe the number of pixels along each axis. For a proportional resize, both axes change by the same factor. Forcing a shared width and height on sources of different shapes makes the image content stretch unless the workflow explicitly crops or adds padding. The cover and reference card in the lab deliberately have different proportions.
Before you begin
Use veylunex-cover.png, which measures 1200 by 800 pixels and 62,824 bytes, plus resize-reference.png, a synthetic card with a circle, a rectangle and text at 960 by 720 pixels and 6,445 bytes. Target a shared width of 600 pixels while keeping each image’s full composition. The corresponding expected heights are 400 for the cover and 450 for the card. The extra resize-squeezed-600x250.png is a deliberately distorted export from the original cover.
Keep the source beside the result and note the width, intended shape and format requested by the destination. A web page may display the same file at several widths. Use a representative actual placement to decide which rendition and details need to be checked. If the destination dictates an exact rectangle, make a separate plan for cropping or padding before resizing.
Steps
Measure the placement and read the source dimensions.
Check how the page uses the image and whether it has a required width, crop or file-size limit. Open both sample sources and record the decoded size with the byte count. A compressed source can contain many pixels, and a simple graphic may use few bytes at a similar width. This is why a file-size requirement does not settle the width decision by itself.
- Identify a shape or detail that will reveal distortion.
- Use a word or graphic detail in the cover and the circle in the reference card.
- Check how these details appear in the original at the intended viewing size so you have a useful comparison when you reopen each export.
Compute each height from its own source.
Multiply the original height by the target width and divide by the original width. Use the nearest whole pixel for the new height. For the measured pair, this gives a 600 by 400 cover and a 600 by 450 card. Keep those expected sizes in the batch notes. A single width can be appropriate for a group with different source shapes.
- If a destination needs identical dimensions for all thumbnails, decide what may be cropped or where padding belongs.
- Compare an intentional crop with the original and check that names, faces, labels or edges important to the recipient are still visible.
- In this particular exercise we keep every edge and use the source proportions.
Resize from the originals and export a matched batch.
Our local test resized both files in Pillow using Lanczos resampling and wrote WebP at quality 85. Use the same original input and these settings if you want to repeat the measured trial. The following loop illustrates how the lab computed the dimensions and named the outputs.
-
from PIL import Image
-
for file, out in [(“veylunex-cover.png”, “resize-cover-600.webp”), (“resize-reference.png”, “resize-reference-600.webp”)]: with Image.open(file) as src: height = round(src.height * 600 / src.width) resized = src.resize((600, height), Image.Resampling.LANCZOS) resized.save(out, “WEBP”, quality=85)
-
If you only need one image from the set, the linked resizer takes an output width and computes its height.
-
Open its actual download and check that the resulting dimensions suit your plan before moving to another source.
-
Open the saved copies and test the failure mode.
Check that the full cover remains in the proportional copy and that the circle in the card still appears round. Open the squeezed cover next. In the local test we requested 600 by 250 directly from the 1200 by 800 source. The width is correct for this page, but the image is visibly shorter than the proportional output and the shape check catches it.
- If you notice the same issue in your batch, return to the original and set the height from its ratio.
- Reopen the corrected download.
- Check both the artwork and the placement in the page, since a layout can distort a correct file when it displays the image in a forced box.
- Keep the dimensions and the page presentation as separate checks.
Check bytes, readable details and the final names.
The cover went from 62,824 to 8,856 bytes and the card from 6,445 to 3,778 bytes in the tested batch. These are measured figures for the particular source images and WebP exports. Use the output table to compare your settings and files. Check fine lines and any text at the display size. If it looks degraded, try a different quality or format from the original and review that download.
- Give working copies meaningful names so the person publishing can identify the correct width and subject.
- Open the finished check copy in the real publishing destination.
- If the destination rejects the format, prepare a supported alternative and check its size and appearance before replacing the file.
Check your result
Have the source pair and finished files open side by side. Confirm that each exported width is 600 and compare the height with the expected value for that original. The lab checked each ratio by multiplying the output height by the original width and comparing it with the original height times the output width. Both proportional files matched. The squeezed sample fails that check.
Download the squeezed error sample to compare the visible distortion with the proportional copy. Measure each downloaded file and compare the readable text, edges and any important shapes. Keep a short batch record with source filename, source dimensions, output filename, output dimensions and actual bytes. Check the digests in the measurement record to identify the downloads from this run. If the files look correct in a viewer, also check the actual layout for unexpected clipping or stretching.
| Source | Original size | Output size | Original bytes | Output bytes |
|---|---|---|---|---|
| veylunex-cover.png | 1200 × 800 | 600 × 400 | 62824 | 8856 |
| resize-reference.png | 960 × 720 | 600 × 450 | 6445 | 3778 |
Common mistakes
Forcing the same width and height across the group. Keep the same target width and calculate height from each file. Re-export the squeezed image rather than stretching its pixels back into shape.
Selecting a file by byte size alone. Check the intended display dimensions and fine details first. Review actual exported byte counts after you know which candidates fit the placement.
Resizing an earlier small export again. Start from the original when preparing a different rendition. Compare fine text and edges in the new download.
Keeping the page preview as the only check. Reopen the actual saved file and compare its dimensions and appearance with the intended asset, then inspect its placement separately.
Limitations
The sizes describe one batch and the measured WebP settings. Exported metadata and color can change between encoders and display environments. Keep the source for uses that depend on its original metadata or quality, and make a separate check of transparency and color when they matter to the destination.
Test record
Tested on 2026-11-23 with Pillow 13.0.0 under Python 3.14.4. The proportional exports kept the target width and passed the ratio check. The explicitly squeezed PNG failed that check.
The measurement record lists the local outputs and their SHA-256 digests.
Tested in
Questions
Can images in a batch share a width and have different heights?
Yes. Use each file’s own ratio. The cover and reference card in the tested batch both have a width of 600, with heights of 400 and 450 respectively.
Why does forcing a certain size stretch an image?
Check whether both axes changed by the same factor. The squeezed cover had the target width and a different height from its proportional copy. Crop or add padding deliberately if you must fit a fixed rectangle.
Does a smaller width always make a smaller file?
Measure the saved export. Dimensions, format, data in the source and the encoding settings all affect byte size. Choose an output based on the combined appearance and delivery checks.
How should I prepare an image that already looks blurry?
Review the original at the size it will be displayed. If the source lacks the required detail, find a better original before preparing the export. Verify it in the actual placement for the page.