Appruva

Serving High-Resolution Photos Fast in a Client Gallery

Thumbnails, previews and originals — and the arithmetic that says which one each screen should get.

To serve high-resolution photos fast, stop sending them. A client's screen can show about 3 million pixels in a lightbox and a fraction of that per grid tile, while a modern camera produces 45 million per frame. A fast gallery makes every upload into three sizes — a roughly 512-pixel thumbnail, a 2048-pixel preview and the untouched original — and serves the smallest one that fills the space, lazy-loading everything below the first screen.

The rest of this post shows the arithmetic behind those sizes, the lazy-loading rule that most often goes wrong, and how to keep private client links cacheable without making them insecure.

Why a 45-megapixel file is the wrong thing to send a browser

A 45-megapixel frame is 8192 × 5464 pixels: 44,761,088 of them. However well it is compressed on disk, the browser cannot draw a JPEG without decoding it first, and a decoded image costs four bytes per pixel (red, green, blue and alpha). That single frame becomes roughly 179 MB of memory the moment it is shown — 44,761,088 × 4 = 179,044,352 bytes.

Now put 48 of them in a grid, which is a modest first screen for a wedding or product gallery. Decoded, that is 48 × 179 MB ≈ 8.6 GB. No phone has that to spare for one browser tab, and most laptops will start dropping images, stuttering on scroll, or reloading the tab. The client experiences this as "the gallery is broken", not "the files are big".

Download is the second cost. File sizes vary enormously with subject and settings, so the numbers below assume a round 2 bits per pixel for a high-quality JPEG — check your own exports and substitute. On that assumption the full frame is 44.76 million × 2 bits ≈ 89.5 megabits, or about 11.2 MB.

179 MBMemory to display one 45 MP frame (pixels × 4 bytes)
16×Fewer pixels in a 2048 px preview than the original
256×Fewer pixels in a 512 px thumbnail than the original

The fix is not "compress harder". Compression shrinks the download but does nothing to the decoded size; only fewer pixels do that. The fix is to never send the client more pixels than their screen can show at the size the image is being drawn.

How to serve high-resolution photos fast: three sizes per frame

Every fast photo gallery does a version of the same thing: it makes each upload into three files and serves the smallest one that fills the space on screen.

SizeLong edgePixelsDecodedAt 2 bits/pxServed when
Thumbnail512 px175,1040.7 MB≈ 44 KBThe grid, filmstrips, selection lists
Preview2048 px2,797,56811.2 MB≈ 0.7 MBThe lightbox, markup, side-by-side compare
Original8192 px44,761,088179 MB≈ 11.2 MBDownload, print, retouching — never on screen by default

The pixel counts assume a 3:2 frame (8192 × 5464, 2048 × 1366, 512 × 342). The last column is the assumed 2 bits per pixel from above, so treat it as a ratio, not a promise.

Why 2048 pixels for the preview

Work backwards from the screens your clients use. A laptop browser window 1440 CSS pixels wide on a 2× display has 2,880 device pixels across; a lightbox that fills about 70% of it needs roughly 2,016. A phone 390 CSS pixels wide at 3× density has 1,170 device pixels across in portrait, and in landscape its height (also 1,170) limits a 3:2 frame to about 1,755 wide. 2048 covers all of those with a little headroom. Going larger buys sharpness only on large external monitors, at a steep cost everywhere else.

Why about 512 for the thumbnail

A grid cell around 200 CSS pixels wide needs 400 device pixels at 2× and 600 at 3×. Anything from 512 to 640 on the long edge looks crisp in a grid; anything bigger is paying preview prices for a postage stamp.

Quality settings matter less than size here, but they still matter for proofing, where clients are judging skin and colour. If you are deciding how far to push them, how much compression a proofing gallery can take works through the artifact thresholds, and JPEG vs HEIC, WebP and AVIF covers whether a newer format earns its compatibility cost.

Lazy loading: what to defer, and the one image you must not

Even with thumbnails, a 600-frame gallery is 600 requests. Browsers can defer images that are off-screen with a single attribute, loading="lazy", which fetches each one shortly before it scrolls into view. For a long grid this is the biggest single win after resizing: the first screen loads, and the rest follows the client's thumb.

Three rules keep it from backfiring:

  • Never lazy-load the first image a visitor sees. A cover photo or the first row of the grid is what the browser measures as the page's main content. Deferring it delays the very thing you want fast. Google's web.dev guidance on Largest Contentful Paint says the same: mark the likely largest image with fetchpriority="high" and do not lazy-load it.
  • Always give images their width and height. Without them the browser does not know how much room to reserve, so the grid jumps as each tile arrives and the client taps the wrong photo. Store the dimensions at upload and write them into the page.
  • Let the browser choose the file. A srcset listing the thumbnail and preview with their widths, plus a sizes hint describing how wide the image is drawn, lets a phone pick the small file and a big monitor the large one, with no JavaScript.
The lightbox trap

Many galleries resize the grid correctly and then open the original when someone taps a photo. On the assumed figures above, that is 11.2 MB and 179 MB of memory for a view the 2048 px preview fills just as well. Check what your lightbox actually requests — open the browser's network panel, tap a photo, and read the file size.

For infinite-scroll galleries, batching helps too: request the next few dozen thumbnails as a group when the client nears the end of what is loaded, rather than one request per tile as each comes into view. Previews for the photos either side of the open one can be fetched in the background so swiping feels instant.

CDNs and caching for private client galleries

A content delivery network keeps copies of your files on servers near the viewer, so a client in Sydney is not fetching every thumbnail from a data centre in Virginia. For a public portfolio, put the images behind a CDN with long cache lifetimes and you are done.

Client galleries are harder, because they are private. The usual way to protect a private image is a signed URL: a link with a token and an expiry, which stops working after a set time. That is good security and, done carelessly, terrible caching. If every page load signs a fresh URL, the browser sees a new address each time and downloads every image again — the client's second visit is as slow as the first.

  • Sign for hours, not seconds. An expiry measured in hours lets the browser reuse what it already has across a review session, while still meaning a leaked link dies the same day.
  • Reuse the signature within a session. Sign a batch once and keep those URLs, instead of re-signing on every scroll or re-render.
  • Sign only the size you are showing. A grid should never hold signed links to originals it is not displaying.

The trade-off is real: a longer expiry is a longer window if a link is forwarded. For a proofing round, a few hours is a reasonable middle; for anything sensitive, shorter links and a slower second visit are the right price.

How fast is fast enough? Measure the grid, not your connection

Google's Core Web Vitals give a useful public yardstick: Largest Contentful Paint — the time until the biggest visible element has rendered — counts as good at 2.5 seconds or less and poor above 4 seconds, measured at the 75th percentile of real visits. For a gallery, the largest element is the cover or the first row of photos.

Here is what the three sizes mean for filling a 48-tile grid on an illustrative 20 Mbit/s mobile connection, using the 2-bits-per-pixel assumption: originals are 48 × 89.5 Mbit ≈ 4,297 Mbit; previews 48 × 5.6 Mbit ≈ 269 Mbit; thumbnails 48 × 0.35 Mbit ≈ 16.8 Mbit. Divide each by 20.

Seconds to download a 48-photo grid at 20 Mbit/s (the two short bars are widened beyond scale to stay visible)
Originals
≈ 215 s
Previews
13 s
Thumbnails
0.8 s

Only the thumbnail grid fits inside the 2.5-second budget, and it does so with room for latency, the page itself and a slower connection. Even previews, which are right for a lightbox, are wrong for a grid.

To test your own gallery, open it in a desktop browser's developer tools, turn on network throttling and a phone-sized viewport, clear the cache, and load the client link — not your logged-in view, which may behave differently. Then watch three things: the size of the first images requested, whether the grid jumps as it fills, and how big the file is when you open a single photo.

Where full resolution still belongs

None of this means clients never get the original. It means the original is fetched for a reason, by an action: a download button, a print order, a zoom to 100% to check focus on eyelashes. Zoom is the one on-screen case, and the honest version loads the full file only after the client asks for it, with a visible indicator while it arrives.

The other place originals belong is the retoucher's machine. The approved frame, and the client's notes on it, need to reach the person doing the work at full resolution — that is a different path from the one a client's phone takes, and keeping the two separate is what lets each be fast.

This is the model Appruva is built on: every frame is stored as the original, a 2048-pixel preview and a small thumbnail; the grid and the review view serve the derivatives, and the original is fetched only when someone zooms past fit or downloads it. Whatever you use, the test is the same — load your own client link on a throttled phone and count the megabytes.

Frequently asked questions

What size should images be for an online photo gallery?

Use about 512 to 640 pixels on the long edge for grid thumbnails and about 2048 pixels for the full-screen view. That covers high-density laptop and phone screens without sending the tens of millions of pixels a modern camera file contains. Keep the original for download and print only.

Does lazy loading hurt photo gallery SEO or speed?

Lazy loading images below the first screen helps speed. Lazy loading the first visible image, such as a cover photo, hurts it, because that image is usually what Google measures as Largest Contentful Paint. Load the cover eagerly with a high fetch priority and lazy-load the rest.

Why is my client photo gallery slow on phones?

The most common cause is serving full-resolution files to the grid or the lightbox. A 45-megapixel frame needs about 179 MB of memory to display, so a grid of them overwhelms a phone even on a fast connection. Check the network panel for the size of the files actually requested.

Do signed URLs stop browsers caching gallery images?

They can. If a new signed URL is generated on every page load, the browser treats each one as a new file and downloads it again. Signing links for a few hours and reusing them within a session keeps images cacheable while still expiring forwarded links.

Should clients ever see the full-resolution original?

Yes, but on request: a download, a print order, or a zoom to 100 percent to check focus. Loading the original by default for viewing costs the client time and memory without showing them anything the 2048-pixel preview does not.