Lorixen.
EN

Customer photo uploads: resizing and formats in a web app

Short answer: When customers or staff upload photos to your web app, don't display the original file. Generate a few resized versions on upload (typically three to five widths), correct the rotation, strip unneeded metadata, store the variants alongside the original and serve them with srcset so each device downloads a size it can use. Most "slow gallery" and "sideways photo" complaints trace back to skipping one of those steps.

Phones take very large photos. A job-tracking app, a marketplace, a property inspection tool or a customer portal that accepts uploads will end up displaying images several times bigger than the screen needs. Below are the symptoms people notice, what causes them and how to fix each one.

Symptom: photo pages load slowly, especially on mobile data

Cause: The app shows the uploaded original, often several megabytes, even in a small thumbnail grid.

Fix: Create resized variants when the file is uploaded and show the smallest one that looks sharp in each spot. web.dev's guide to serving responsive images says serving desktop-sized images to mobile devices can use two to four times more data than needed. It also notes there's no single correct number of versions, but serving three to five sizes of an image is common; more sizes help performance but take more storage and slightly more HTML.

A practical starting set for an app:

  • A small thumbnail for lists and grids
  • A medium version for detail views on phones
  • A large version for desktop and zoom
  • The untouched original, kept privately for downloads or reprocessing

Symptom: the right image size never seems to get chosen

Cause: The page uses a single src without telling the browser what alternatives exist or how wide the image will appear.

Fix: Use the srcset and sizes attributes. MDN's guide to responsive images explains these attributes, together with the <picture> element, handle two problems: resolution switching (same image, different pixel counts) and art direction (different crops for different layouts). It notes that srcset, sizes and <picture> are supported in modern desktop and mobile browsers.

For uploaded photos, resolution switching is usually all you need: list your variants in srcset with their widths, and describe the layout in sizes (for example, full width on phones, a third of the width on desktop). The browser then picks the most suitable file.

Symptom: photos appear sideways or upside down

Cause: Many phones save the image the same way regardless of how the phone was held and record the intended rotation in EXIF metadata. Some processing steps or older tools ignore that tag, so the resized version comes out rotated wrongly.

Fix: Apply the orientation during processing so the pixels themselves are the right way up, then remove the orientation tag from the variants. MDN documents the CSS image-orientation property, whose from-image value uses the image's EXIF data, but fixing orientation at upload time means every variant is correct no matter where it's shown, including in emails and PDFs your app generates.

Symptom: uploads fail or time out

Cause: Large files are sent through your app server, which hits request-size or time limits, or the server tries to resize huge images synchronously while the user waits.

Fix:

  • Set a sensible maximum file size and say so on the upload screen.
  • Upload directly to storage where possible, then process images in a background job.
  • Show the user a progress indicator and a placeholder until the variants are ready.
  • Reject or convert unusual formats with a clear message rather than a generic error.

Symptom: privacy questions about uploaded photos

Cause: Photo metadata can include details such as device information and, depending on the phone's settings, location.

Fix: Strip metadata you don't need from the variants you display. Keep the original private if you have a business reason to retain it, and decide how long you keep it. Check your rules where you operate about personal data in images.

Symptom: images look soft or blurry on high-resolution screens

Cause: The largest variant is too small for high-density displays, or sizes understates how wide the image is displayed, so the browser picks a version that's too small.

Fix: Make sure the largest variant is wide enough for the biggest layout times the device pixel density you care about, and check sizes against the real layout. Your browser's developer tools show which file was chosen and how large it rendered.

Symptom: storage keeps growing faster than expected

Cause: Variants are regenerated on every edit, abandoned uploads are never cleaned up, or every size is generated for images that are only ever shown small.

Fix:

  • Generate variants once per upload and only regenerate when you change your size set.
  • Delete variants when the original is deleted.
  • Clean up uploads that were started but never attached to a record.
  • Review your size list: if nobody sees the largest version, drop it.

Choosing how to resize

web.dev names two widely used tools: the sharp package for Node.js, which it describes as a good choice for automating resizing, and ImageMagick, which is convenient for one-off resizing from the command line. Many frameworks and hosting platforms also offer built-in image pipelines, and hosted image services can resize on the fly. Which route fits depends on your stack and on how many images you process; a background job using a resizing library is often enough for a small business app.

A short checklist

  • Variants generated on upload (three to five sizes)
  • Orientation corrected in the pixels
  • Unneeded metadata stripped from displayed images
  • srcset and sizes on every user photo
  • Width and height attributes set to avoid layout jumps
  • Lazy loading for images below the fold
  • File-size limit stated on the upload screen
  • Clean-up for deleted and abandoned uploads

FAQ

Should I convert uploads to WebP or AVIF?

Modern formats can reduce file size, and serving them through <picture> with a JPEG fallback is a common pattern. Test quality and processing time with your own photos before switching everything.

Do I still need the original file?

Often yes: for downloads, for reprocessing when you add a new size, or for evidence in inspection-type apps. Keep it private and don't display it directly.

Can't the browser just shrink a large image?

It can display it smaller, but it still downloads the full file. Resizing on the server saves data and speeds up pages.

How big should thumbnails be?

Size them to the largest width they're displayed at, allowing for high-density screens. Your layout decides the number, not a universal rule.

Is your app's photo gallery slow, or are customers' pictures arriving sideways? Tell us how images flow through your app and we'll pinpoint where to fix it.

Sources

WhatsAppLet’s talk