Images for No-Code Sites: Sizes, Formats and the Weight of the Whole Page
Prepare product photos before uploading them to a builder: resize and compress real images, compare JPEG and WebP sizes, calculate the weight of a gallery page before and after, and check the files by reading them back.
In this lesson you will
- Resize photos before uploading
- Compare JPEG and WebP quality and size
- Calculate page weight
- Check the files independently
About 28 minutes
Twelve candles, forty megabytes
Priya photographed her candles with a phone, 4,000 pixels wide, and dropped twelve pictures into the shop page. It looked fine on her laptop and took half a minute to load on her customer’s phone. A no-code builder helps, since many resize and convert images for you, but not always, and not for every plan, so it is worth knowing what to upload. The rule is the one from the Web design course: send the browser no more pixels than it displays. A product card that appears 400 pixels wide on a phone and 600 on a desktop needs a file about 600 to 1,200 pixels wide, with the larger number for sharp screens, and not 4,000.
Three choices decide the weight of an image: its dimensions, its format and its quality setting. JPEG is the standard for photographs, and a quality of about 75 to 85 usually looks the same as the original with a file a fraction of the size. WebP is a newer format, supported by current browsers, that makes smaller files for the same quality. PNG is for graphics with flat colours and transparency, and is large for photos. Page weight, the sum of all files a page loads, matters for speed and for visitors with limited data, and a simple budget helps: a typical guideline is to keep a page under about 1 to 2 megabytes, and Priya’s should be well below that. Whatever the builder does, check the result by measuring the page, as in lesson 10.
| Choice | Effect on size |
|---|---|
| Fewer pixels | Size falls roughly with the number of pixels |
| JPEG quality 80 instead of 100 | Often 3 to 5 times smaller |
| WebP instead of JPEG | Often about a quarter smaller or more |
| PNG for a photo | Much larger than JPEG |
from PIL import Image
import numpy as np, io, json
rng = np.random.default_rng(3)
def photo(w, h):
y, x = np.mgrid[0:h, 0:w]
base = np.stack([150 + 80 * np.sin(x / 90.0 + y / 200.0), 120 + 70 * np.cos(y / 70.0), 100 + 90 * np.sin((x + 2 * y) / 160.0)], axis=2)
return Image.fromarray(np.clip(base + rng.normal(0, 7, (h, w, 3)), 0, 255).astype("uint8"))
def size(img, fmt, q=None):
b = io.BytesIO(); img.save(b, fmt, **({"quality": q} if q else {})); return len(b.getvalue()), b.getvalue()
original = photo(2000, 1333) # stands in for a 4000 px phone photo, scaled down to keep the run quick
sizes = {}
sizes["original, JPEG quality 100"] = size(original, "JPEG", 100)[0]
sizes["original as PNG"] = size(original, "PNG")[0]
card = original.resize((800, 533))
for q in (95, 80, 60): sizes["card 800 px JPEG q%d" % q] = size(card, "JPEG", q)[0]
sizes["card 800 px WebP q80"] = size(card, "WEBP", 80)[0]
for k, v in sizes.items(): print(k.ljust(30), "%9d bytes" % v)
before = 12 * sizes["original, JPEG quality 100"]
after = 12 * sizes["card 800 px JPEG q80"]
print("12 photos as uploaded: %.1f MB | after resizing to 800 px and quality 80: %.2f MB | saved %.1f%%" % (before / 1e6, after / 1e6, 100 * (1 - after / before)))
blob = size(card, "JPEG", 80)[1]; back = Image.open(io.BytesIO(blob))
print("re-opened file:", back.format, back.size, "| bytes equal what was measured:", len(blob) == sizes["card 800 px JPEG q80"])
print("DATA " + json.dumps({"sizes": sizes, "before": before, "after": after, "fmt": back.format, "dim": list(back.size)}))
original, JPEG quality 100 2426110 bytes
original as PNG 5394654 bytes
card 800 px JPEG q95 97449 bytes
card 800 px JPEG q80 33357 bytes
card 800 px JPEG q60 20839 bytes
card 800 px WebP q80 11802 bytes
12 photos as uploaded: 29.1 MB | after resizing to 800 px and quality 80: 0.40 MB | saved 98.6%
re-opened file: JPEG (800, 533) | bytes equal what was measured: True
The program made a synthetic photograph of 2,000 by 1,333 pixels, with smooth colour and noise like a real photo, and saved it in several ways, so that the sizes are real measurements. Saved as a JPEG at maximum quality it is 2,426,110 bytes, and as a PNG, the wrong format for a photo, 5,394,654. Resized to a card width of 800 pixels, the JPEG at quality 95 is 97,449 bytes, at 80 it is 33,357, and at 60 it is 20,839. WebP at quality 80 gives 11,802, which is 35 percent of the JPEG’s size. Each step, fewer pixels, a sensible quality, a better format, takes away bytes that the visitor would not see.
For the shop page of twelve products, the difference is large: twelve photos as uploaded weigh 29.1 megabytes, and twelve resized cards at quality 80 weigh 0.40 megabytes, a saving of 99 percent. On a mobile connection that is the difference between a page that appears after a few seconds and one that never seems to finish. The numbers come from a synthetic image, and the exact figures for real photographs differ, since noisy detail compresses worse and smooth backgrounds compress better, so measure your own pictures. Many builders offer to “optimise images” automatically, and some limit it to paid plans, so check what yours does and still upload sensible sizes.
Independent check: the JPEG for the card was written to memory and opened again with a separate decoding call, which confirmed that it is a valid JPEG of 800 by 533 pixels and that the number of bytes equals the measured size. The ordering of sizes, higher quality larger, PNG larger than JPEG, WebP smaller than JPEG at the same quality setting, was asserted by the program. The saving is plain arithmetic on the measured sizes, and no image library is needed to check it.
Check by hand: the 2,000 pixel wide photo is resized to 800 wide, and 800 / 2,000 is 0.4, so the height becomes 1,333 x 0.4 = 533. The area is 0.4 x 0.4 = 0.16, or 16 percent, of the original, which is why the file shrinks so much even before the quality setting does its part.
A modern camera or phone photo can be 5 megabytes or more. Resize it to the largest size your layout needs, and keep the original in a safe place.
Use a descriptive file name such as lavender-candle.jpg and write alt text that describes the picture. It helps search engines and visitors who use screen readers, and lesson 9 returns to it.
Builders, plans and prices change often, so the lessons use generic labels such as Builder A and describe categories of tools, and you must check each vendor’s current website for features, prices and limits. Every calculation and check in this lesson was run while the course was written, in Python 3.13 or Node.js 22, on sample data that the lesson provides, with a second independent calculation. The image in this lesson is synthetic. Real photographs compress differently, so measure your own. Check what your builder resizes and converts automatically.
Practice
Resize three of your own photos to 1,200 pixels wide at quality 80 and compare the file sizes. Convert one to WebP and compare. Add up the weight of the images on one of your pages.
Check what you learned
Five quick questions. Pick an answer and you will see straight away whether it is right and why.
What is the best format for photographs on most sites?
- JPEG or WebP
- PNG
- BMP
- TIFF
PNG is for flat graphics.
Why resize photos before upload?
- Builders cannot store large files
- Photos lose colour
- Search engines require it
- The browser should not download more pixels than it shows
Weight and speed.
Roughly how does file size change with fewer pixels?
- It stays equal
- It doubles
- It becomes zero
- It falls with the number of pixels
Area, not width.
What is a sensible JPEG quality range for photos?
- 1 to 10
- 100 always
- About 75 to 85
- Below 20
Look at the result.
How can you check that an image file is what you think?
- Rename it
- Zip it
- Reopen it and read its format and size
- Print it
An independent check.
Summary
- Send the browser no more pixels than it shows.
- JPEG or WebP at quality about 75 to 85 for photos.
- Calculate and budget the page weight.
- Verify files by reading them back.
Questions
Does the builder compress images for me?
Many do some resizing and conversion, with differences between vendors and plans. Check the documentation, and test by measuring the page, since you cannot assume it.
What about video?
Video is much heavier than images. Host it on a video service and embed it, instead of uploading large files to the builder, and do not autoplay with sound.
What is a good page weight?
A common guideline is to stay under about 1 to 2 megabytes for a normal page. Lower is better for phones. Lesson 10 shows how to measure it.
