MAGODUCK

Category: Resizing

  • Resize Website Images for Mobile and Desktop

    Resize Website Images for Mobile and Desktop

    Quick answer

    Match the largest real display slot and provide smaller responsive copies where appropriate. In this sample, resizing a 900 × 600 JPEG to 450 × 300 at the same quality used 60.2% fewer bytes. Changing CSS width alone still serves the same source file.

    Examples checked November 11, 2026.

    Evidence and accountability: read our testing methodology, contributor profile and editorial and corrections policy. The dated examples are specific tests, not a guarantee for every file or device.

    The downloadable illustration example isolates pixel dimensions and encoded bytes. Use your own page’s network and performance measurements to assess delivery.

    Why resize images at all?

    A browser cares about the file you give it, not the size of the CSS box you eventually draw. If a 4000×2250 JPEG is placed in a 600 CSS-pixel column, CSS can make the picture look 600 pixels wide while the source remains a 4000-pixel image. Unless responsive source logic gives the browser a smaller alternative, you can still send every byte of that large file.

    The same illustration at JPEG quality 85 used 66,694 bytes at 900 × 600 and 26,576 bytes at 450 × 300.

    Resizing vs compression vs cropping

    Four operations that are easy to mix up
    Operation What changes Typical purpose
    Resize Pixel dimensions Match the resource to a real display need
    Compress / encode How pixels are stored Reduce bytes at a chosen quality level
    Crop Framing / included content Change composition or aspect ratio
    Format conversion File format / coding features Use a format suited to delivery or compatibility

    For ordinary web delivery, a useful workflow is often to choose the dimensions first, then encode that derivative efficiently. A tool can combine both operations, but the concepts are still separate.

    Aspect ratio: resize without stretching

    For proportional resizing, preserve the width-to-height relationship. A 16:9 image can be made smaller without changing its shape; forcing it into a square by simply changing width and height distorts faces and objects. If you need a different shape, crop intentionally instead of stretching.

    Proportional image resize compared with a visibly stretched resize.
    Resizing preserves geometry when the aspect ratio stays consistent. Cropping is the correct tool when the framing itself needs to change.

    How large should a website image be?

    There is no honest universal answer such as “every website image should be 1200px wide.” Start with the largest real CSS slot. Then decide whether a higher-density display justifies an upper source with more pixels. A 600 CSS-pixel content image might reasonably have a 600-ish source for 1× use and an upper source around 1200 pixels for a 2× case, but the browser should not be forced to send that upper file to every visitor.

    Halving width and height quarters the pixel count. Encoded byte size depends on image content and encoder settings, so measure the saved file too.

    Do you need 300 DPI for web images?

    No. Print-oriented DPI/PPI metadata is not the main sizing control for ordinary website rendering. What matters for a raster image on the web is primarily the source pixel dimensions, the CSS layout size and the device’s pixel density. A 1200-pixel-wide file does not become sharper on a webpage merely because its metadata says 300 DPI instead of 72 DPI.

    What device pixel ratio changes

    Device pixel ratio relates physical pixels to CSS pixels. A 450 CSS-pixel slot on a 2× display can use a 900-pixel candidate. Provide appropriately sized candidates and check which one your browser selects.

    Download the two-width JPEG test

    Both exports started from the same decoded illustration and used Chromium Canvas JPEG quality 0.85. The smaller copy was drawn at half the width with aspect ratio maintained.

    Same illustration and JPEG quality, different widths
    Export Dimensions File size
    Original-width export 900 × 600 66,694 bytes
    Half-width export 450 × 300 26,576 bytes
    The same illustration resized to 450 by 300 pixels
    The half-width export from the comparison.

    When does quality become noticeably softer?

    At normal display size, downscaling can look excellent long after a 100% crop reveals fewer source pixels. That distinction matters: a difference visible only after aggressive pixel-peeping may not matter to the reader. For our 600 CSS-pixel example, the 600w source is a sensible 1× candidate, while the browser selected 1200w at DPR 2 to preserve more detail on the higher-density display.

    Screenshot and text resize test

    Small type and thin UI strokes can become hard to read after aggressive downsizing. Inspect the intended display size and choose a larger candidate if necessary.

    Upscaling does not recreate missing original detail

    When a small raster image is enlarged, new pixels have to be interpolated or synthesized. Traditional resizing can make the file dimensions larger, but it cannot reconstruct genuine detail that was never present. AI upscaling is a different process and may synthesize plausible detail; that is not the same as recovering the original scene.

    Responsive images: one image is not always enough

    srcset lets you offer several resolution candidates. With width descriptors, each w value must match the source’s real intrinsic width. The sizes attribute describes the image’s intended layout slot so the browser can choose a candidate appropriate to that slot, DPR, zoom and its own selection logic.

    <img
      src="photo-1200.jpg"
      srcset="photo-480.jpg 480w,
              photo-768.jpg 768w,
              photo-1200.jpg 1200w,
              photo-1600.jpg 1600w"
      sizes="(max-width: 948px) calc(100vw - 48px), 900px"
      width="1600"
      height="900"
      alt="...">

    Inspect the selected URL in browser developer tools. Test a narrow viewport and a high-density display before committing to the set of candidates.

    2026 update: sizes="auto" for lazy-loaded images

    For lazy-loaded images, modern browsers can use sizes="auto" where supported. Provide sensible fallback sizes and confirm the selected source in your target browsers.

    <img
      loading="lazy"
      src="photo-1600.jpg"
      srcset="photo-480.jpg 480w, photo-768.jpg 768w,
              photo-1200.jpg 1200w, photo-1600.jpg 1600w"
      sizes="auto, (max-width: 948px) calc(100vw - 48px), 900px"
      width="1600" height="900" alt="...">

    Keep the fallback sizes after auto for compatibility. Do not use this as an excuse to lazy-load an above-the-fold LCP hero.

    Width and height attributes are about layout stability

    Adding correct intrinsic width and height lets the browser calculate an aspect ratio before the image finishes loading, so it can reserve space and reduce layout-shift risk. Those attributes do not magically change the number of bytes downloaded from the URL.

    Check actual image delivery

    On a test page, compare the Network panel at mobile and desktop widths. Record the actual image URL, bytes transferred and rendered dimensions.

    Use a performance trace to determine whether image discovery, transfer, decoding or another page dependency contributes to the LCP delay.

    Does resizing improve LCP?

    Reducing the size of an oversized LCP image can help when its download is a bottleneck. Load discovery, caching and layout also influence LCP.

    Should you lazy-load website images?

    Below-the-fold images can benefit from native loading="lazy". The likely LCP hero should normally be discoverable directly in the HTML and should not be lazily loaded. A justified fetchpriority="high" hint can help an important LCP image, but it is a priority hint, not something to apply to every image.

    Resize first or compress first?

    A practical workflow is usually to decide the required pixel dimensions, create the derivative, then encode/compress that derivative at an appropriate setting. Some pipelines combine both steps. The important thing is not to obsess over format or quality while still serving far more pixels than the layout needs.

    This is also why a correctly resized JPEG can be lighter than an unnecessarily large WebP: format choice is only one part of web image delivery.

    WordPress already helps—but it cannot read your mind

    WordPress has generated image sub-sizes and responsive srcset/sizes markup for years. That can save bandwidth, but the result still depends on your theme, plugins, available image sizes and the markup you output. If a theme declares an inaccurate sizes value or hard-codes the full image, the browser can still select more pixels than necessary.

    Common mistakes

    • Uploading a 6000px photo for a 600px content slot.
    • Using CSS width as the only optimization.
    • Stretching dimensions instead of preserving aspect ratio.
    • Upscaling a tiny image and expecting original detail to return.
    • Serving one source width to every screen.
    • Using too-small sources on high-DPR displays.
    • Forgetting compression/encoding after resizing.
    • Lazy-loading the likely LCP hero.
    • Omitting intrinsic width and height.
    • Generating dozens of derivative widths nobody selects.
    • Judging quality only at extreme zoom.
    • Deleting the original master after producing website derivatives.

    A practical resize workflow

    Use the Image Resizer to make a copy at the required width. Open it in the Image Dimensions Checker to confirm the saved dimensions.

    1. Measure the largest real slot. Inspect the layout, not the source photo.
    2. Preserve aspect ratio. Crop intentionally when the shape must change.
    3. Plan a sensible upper high-DPR source. Do not automatically ship the camera original.
    4. Create smaller width candidates. Pick widths that match real breakpoints/slots instead of arbitrary dozens.
    5. Encode each derivative efficiently.
    6. Write accurate srcset descriptors and sizes.
    7. Reserve width and height.
    8. Keep the LCP image eager and discoverable.
    9. Check currentSrc in a browser. Verify mobile is truly receiving a smaller candidate.
    10. Keep the master. Website files are derivatives, not your archive.
    Decision guide for choosing website image dimensions from the real CSS slot through DPR, responsive widths, encoding and browser verification.
    Start with the real layout need, then create enough candidates for useful browser choices. Do not begin with a universal pixel number.
    Download the resize checklist

    The checklist summarizes the delivery workflow; the article and datasets contain the evidence behind it.

    Download PNG checklist

    MAGODUCK ten-step web image resize checklist covering display slot, aspect ratio, DPR, responsive widths, encoding and verification.
    A compact pre-publish checklist for website image resizing.

    How the exports were measured

    We ran these exports on November 11, 2026 in Chromium 156.0.8078.79. We decoded each source, drew it at the stated dimensions, encoded it with Canvas, and reopened the output. The measurement file with settings and SHA-256 hashes records file sizes and decoded pixel counts. Run node tests/blog-examples-v498.cjs /path/to/outputs from the plugin with Playwright and Chromium installed. Encoders can differ across browser versions.

    For reference, the earlier reported tables (CSV) record the previous article figures. The original inputs for those figures are unavailable. The examples above use the downloadable files shown here.

    Sources

    Short FAQ

    What width should I export for an image displayed at 400 CSS pixels?

    Test a 400-pixel file for a 1× screen and an 800-pixel candidate for a 2× screen. Set responsive sizes for the layout and verify which file the browser requests.

    What size should website images be?

    Match the largest real rendered slot and provide responsive candidates for smaller layouts and higher DPRs. There is no universal 1200px rule.

    Does CSS resize an image file?

    No. CSS changes rendered size. Without a smaller source or responsive selection, the browser may still receive the original large file.

    Does resizing reduce file size?

    Usually when you reduce raster dimensions, because there are fewer pixels to encode. The exact byte reduction also depends on content, format, quality and encoder.

    How large should images be for Retina displays?

    A higher-DPR display can benefit from more source pixels than CSS pixels. In our 600px-slot test Chromium selected 600w at DPR 1 and 1200w at DPR 2, but that is an example—not a rule that every image must be exactly 2×.

    What does sizes do?

    With width-descriptor srcset, it tells the browser the intended layout slot width so it can choose an appropriate candidate.

    Does resizing improve LCP?

    It can reduce payload pressure when the LCP image is oversized, but LCP also depends on server timing, discovery, network, rendering and other work.

    Is 300 DPI needed for the web?

    No. Website raster display is driven primarily by source pixels, CSS dimensions and device pixel density, not print DPI metadata.

    Does upscaling improve quality?

    It can make dimensions larger, but normal resampling cannot restore genuine missing detail that was never in the source.

    Editorial transparency: This guide was drafted with AI assistance. The 900 × 600 and 450 × 300 JPEGs verify one size-and-dimensions example. Use your own responsive layout and network measurements to decide what image widths visitors actually receive.

    The practical rule

    Deliver enough pixels for the real slot, not every pixel in the master. Preserve the original separately, generate a sensible set of derivatives, encode them efficiently, declare accurate srcset/sizes, keep the LCP source discoverable, and verify what the browser actually selects.