Image Resizer

The left pane is the original sample grid. The right pane resamples it to the width and height you type. With the aspect ratio locked, the other side follows width divided by height. Under that picture you pick JPEG, PNG, or WebP; JPEG and WebP quality sit there too. The quality number only changes this encode’s quantization, not how many pixels were computed.

Resizing changes the sample grid, then a codec writes new bytes

Pixel width and height count samples. Resampling builds a new grid: enlarging interpolates samples that were not captured, and shrinking folds several samples into one. The aspect ratio is width divided by height. Locking it keeps both axes on that same scale, so a circle stays a circle. JPEG or WebP then quantizes the new samples; PNG stores those samples without a second lossy step. Byte size is a different ledger — compare it in the image compressor, or turn the bytes into text with image to Base64.

What width, height, and a new encode actually change

Why pixel width and height are a sample grid, not a length in centimeters

  1. The file’s width and height count samples across and down. They are not centimeters.
  2. Print size is that count divided by a density, often pixels per inch. 1800×1200 at 300 ppi is about 6×4 inches.
  3. The same samples at 72 ppi describe a larger print. The grid itself did not gain detail.
  4. A canvas re-encode usually drops the old EXIF and density tag, so a reader falls back to its own default density.

Why a locked aspect ratio forces both axes to share one scale factor

  1. Aspect ratio is width divided by height. A 1600×900 picture is 16:9.
  2. With the lock on, the other side is original opposite side times the new side, divided by the original side.
  3. That quotient is rounded to a whole pixel, so the result can be off by one sample.
  4. Unlocking lets the two scale factors differ. The picture is resampled into a new rectangle and looks stretched. The lock does not crop or pad.

Why enlarging invents samples and shrinking throws high frequencies away

  1. Upscaling inserts samples between the ones the camera captured. Interpolation cannot recover detail that was never stored.
  2. A soft kernel blurs edges. A sharper kernel can ring. Either way the information ceiling is the smaller grid.
  3. Downscaling packs several samples into one. Edges and text thinner than the new cell are mixed away or lost.
  4. Enlarging afterward does not restore those frequencies. A GIF is a sequence of frames; one raster encode keeps a single frame.

Why the file’s byte size does not scale with the number of pixels

  1. JPEG and WebP quantize. The quality number changes the step size, not the pixel count. 100 is still lossy.
  2. PNG is lossless for the resampled pixels. The resample itself has already replaced the old grid.
  3. JPEG has no alpha. Transparent pixels become opaque, commonly against black. PNG and WebP can keep alpha.
  4. A noisy small PNG can outweigh a smooth large JPEG. Pixel count and byte count are separate accounts.

Where the sample grid and the container part ways

A layout that needs a fixed pixel box

A slot of 1200×630 still holds whatever samples you give it, scaled by CSS. Resampling to that box changes the stored grid. CSS scaling does not. If the two scale factors differ, the picture stretches; a locked ratio keeps the original rectangle.

An iPhone still that is still a HEIF container

HEIC is HEVC inside HEIF. A decoder that only knows JPEG, PNG, GIF, and WebP never obtains that sample grid, so there is no width or height to recompute. The still has to be decoded and written as JPEG first, which is what HEIC to JPG does.

Frequently asked questions

What is the difference between resizing and compressing an image?
Resizing changes the sample grid: how many pixels across and how many down. Compression changes how those pixels are coded into bytes. A 1200×800 picture kept at 1200×800 and re-encoded as JPEG at a coarser quality still has the same number of samples, but more high-frequency coefficients are rounded away, so the file usually shrinks and fine texture softens. Shrinking 4000×3000 to 800×600 really does discard detail finer than the new cell. If that smaller grid is then encoded at a very fine quality, the file is not guaranteed to be smaller than the original. The two ledgers are the pixel grid and the coded bytes. Exact pixels are a resample. A smaller file with no particular pixel target is a different operation, and that comparison belongs with an image compressor.
What does locking the aspect ratio actually calculate?
The aspect ratio is width divided by height. A 1600×900 picture is 16:9. With the lock on, editing one side recomputes the other so both axes use the same scale: new height is about new width times original height divided by original width, then rounded to a whole pixel. That rounding can leave the result one pixel off the exact ratio. Circles stay circles because the two scale factors match. With the lock off, width and height are scaled independently, the rectangle’s ratio changes, and resampling stretches the picture wider or taller. Locking does not crop a window out of the photo and does not add bars. It only refuses two different scale factors.
Does enlarging a picture make it sharper?
No new detail appears. Enlarging inserts samples between the ones that were captured. Bilinear-style interpolation weights the neighbors, so edges get softer. A sharper kernel can outline those edges with a halo. The file has more pixels and often more bytes, but the information is still the smaller original. Encoding that result as JPEG quantizes again, and block edges and banding usually become easier to see. The ceiling on sharpness is the original sampling, not the larger width and height you typed. A later downsample cannot negotiate that back: the invented samples were never measurements.
What do you lose when you shrink an image?
Shrinking folds several samples into one. Edges, texture, and strokes of text that are thinner than the new cell do not fit, so they blend into a neighbor or disappear. The picture can still be recognizable. The contour remains and the high frequencies do not. Skipping a low-pass step before the downsample can add moiré or jagged edges, because the old grid’s fine pattern aliases into the new one. An integer scale is often cleaner than an awkward ratio such as 137 percent, since the sample phase lines up, but the discarded frequencies still do not come back. Enlarging afterward only interpolates the coarser grid.
Are pixel dimensions the same thing as centimeters or inches?
No. Width and height in the file count samples. Centimeters or inches need a density on top of that count, usually written as pixels per inch. An 1800×1200 grid at 300 ppi is about 6 by 4 inches. The same samples read at 72 ppi describe a larger print, and no extra detail was created. Changing the pixel width changes the sample grid. It does not, by itself, write a physical length. A fresh encode from a canvas typically does not carry the old EXIF block or the density tag, so a reader applies whatever default density it uses. If you need a specific print size, you need both the pixel count and an explicit density, not the pixel count alone.
Does a GIF stay animated after you resize it?
An animated GIF is a sequence of frames, each a raster, plus a delay between frames. Resampling draws the frame the decoder currently presents into the new width and height, then encodes one JPEG, PNG, or WebP. The new file has no timeline, so it does not loop. GIF transparency is an index in the palette, not a general alpha channel. A JPEG encode has no alpha, so those pixels become opaque. Keeping every frame means resampling each one and writing them back into an animation container. A single raster cannot store the sequence, the delays, or the disposal method. The motion is a property of the container, not of the pixel width.
Does PNG transparency survive a resize to JPEG?
PNG can store alpha: each pixel has color and an opacity. JPEG has no alpha channel. When a canvas encodes a picture with transparency as JPEG, the transparent pixels become opaque, commonly against black, because the missing color has to be filled before the lossy encode. PNG and WebP can keep the alpha of the resampled pixels. Separately, a JPEG or WebP quality number selects a quantization step. 100 is the finest step that control offers, and it is still lossy; chroma is often subsampled even at the top of the scale. PNG is lossless for the pixels after resampling. It is not a way to recover detail the resample already replaced, and it is not a way to sneak alpha into JPEG.
Why doesn’t changing width and height always shrink the file?
Byte size is dominated by the codec, not by a linear function of the pixel count. A noisy small PNG can be larger than a smooth large JPEG, because PNG pays for every unpredictable sample and JPEG spends bits on what survives quantization. Raising quality uses a finer step, so the same width and height occupy more bytes. Moving from PNG to JPEG drops alpha and introduces quantization, so the file often shrinks and the pixels are no longer identical. Enlarging a JPEG and saving JPEG again adds samples and quantizes a second time, so the file often grows and looks softer. The pixel grid and the byte count are two accounts. Matching a pixel box does not promise a smaller file, and a smaller file does not promise the same grid.