Image Compressor

The left pane is the original picture. The right pane is that picture encoded again. A longest-edge cap above 0 scales the longer side down to that many pixels and the other side by the same factor; 0 leaves the sample grid alone. Under the result you pick JPEG, PNG, or WebP. JPEG and WebP also take a quality number, which sets the quantization step, not a guaranteed file size.

Compression rewrites the bytes; it does not promise a smaller file

JPEG and WebP quantize. The quality number changes the step size of that rounding, so high-frequency detail goes first and the byte count usually falls. It does not set the pixel count, and the same number is not the same table in JPEG and WebP. A longest-edge cap is a different operation: it scales both axes so the longer side fits, then the codec encodes that new grid. Exact width and height belong in image resize. The bytes can also be written out as text with image to Base64.

What quality, the sample grid, and the byte count each change

Why the quality number is a quantization step, not a share of the file

  1. Baseline JPEG splits the picture into 8×8 blocks, runs a DCT, then rounds the coefficients with a quantization table.
  2. The quality control scales that table. A coarser step zeros high-frequency coefficients first: fine texture and weak edges.
  3. 100 is still lossy. Chroma is often subsampled, commonly 4:2:0, even at the top of the scale.
  4. WebP has its own tables. JPEG 80 and WebP 80 are not the same step, so the byte counts are not interchangeable.

Why a PNG often stays large when a photo is “compressed”

  1. PNG stores filtered pixels and then DEFLATE. For those pixels the encode is lossless.
  2. There is no JPEG-style quality step, so a quality control does not apply to PNG.
  3. A photograph is noisy and hard to predict, so DEFLATE saves little and a photo PNG is often several times a JPEG.
  4. Flat color, screenshots, and line art predict well, which is why those pictures stay small as PNG. Moving a photo to JPEG or WebP drops alpha.

Why a longest-edge cap resamples the grid instead of cropping it

  1. The cap looks at the longer of width and height. If that side is already within the cap, the grid stays put.
  2. If it is longer, both axes share one scale so the long side lands on the cap. The aspect ratio stays. Corners are not cut off.
  3. Rounding to whole pixels can leave the result a sample off the exact ratio.
  4. The new grid is then quantized if the codec is JPEG or WebP. Fewer samples and coarser steps are two separate losses.

Why encoding again can make the file larger

  1. A JPEG is decoded to pixels that already include the old rounding, then encoded with a new table. That is a second generation.
  2. A file that was already tightly quantized can grow, and the blocks can become easier to see. The extra bytes are not extra detail.
  3. PNG to PNG can move either way, because the filters and the DEFLATE settings need not match the previous encoder.
  4. Enlarging the grid and then encoding adds samples. More samples usually mean more bytes, not a sharper photograph.

Where the codec and the container are not the same problem

A page budget that counts bytes, not pixels

A 4000×3000 JPEG can miss a byte budget even when the layout only shows it at 800 pixels wide. Lowering quality keeps the sample grid and spends fewer bits on high frequencies. Capping the long edge changes the grid first. The two do not substitute for each other.

An iPhone still that is still HEVC in a HEIF box

HEIC is not a JPEG bitstream, so there is no JPEG quantization table to coarsen until the still is decoded and written as JPEG. That step is HEIC to JPG. The JPEG that comes out can then be quantized further.

Frequently asked questions

How does image quality relate to compression?
The quality number is not “make the file this percent of the original.” Baseline JPEG divides the picture into 8×8 blocks, transforms them with a DCT, and rounds the coefficients against a quantization table. The control scales that table. A coarser step turns high-frequency coefficients into zeros first, so fine texture and weak edges go, and the byte count usually drops. WebP quantizes too, but its tables are not JPEG’s tables: 80 on one scale and 80 on the other are not the same rounding, and neither the look nor the size converts by the number alone. 100 is still lossy. Chroma is often left at 4:2:0, and the number does not decide how many pixels the grid has.
What is the difference between compressing and resizing?
Compression changes how samples are written as bytes. Resizing changes how many samples there are across and down. On a 4000×3000 picture, lowering JPEG quality can leave the pixel count untouched and still discard the high frequencies that quantization zeros out. Capping the long edge at 1600 first scales the grid by one factor, so detail finer than the new cell is gone, and then the codec writes bytes for that smaller grid. The two ledgers stay separate. A cap always follows the longer side. Naming an exact width and an exact height, and letting the other side be derived or not, is the resize operation, which is what image resize is for.
Why is a PNG still large after compression?
PNG filters the pixels and then DEFLATE. For the pixels that come out, that is lossless. There is no JPEG quality step, so turning a quality control down does nothing to a PNG. A photograph is noisy and poorly predicted, so DEFLATE has little to exploit and a photo PNG is often several times the size of a JPEG of the same scene. Flat color, screenshots, and line drawings predict well, which is why those stay small as PNG. Making a photograph obviously smaller means a codec that quantizes, JPEG or WebP, or fewer samples in the grid. JPEG has no alpha, so a transparent PNG that becomes JPEG fills those pixels in, commonly against black.
Is JPEG quality 100 lossless?
No. 100 is the finest quantization step that control offers. The rounding after the DCT is still there. Many encoders keep chroma subsampling, often 4:2:0, even at the top of the scale, so color resolution stays below luma. Baseline JPEG is still 8 bits per channel. Saving an already compressed JPEG again at 100 does not restore the coefficients from before the first quantization. It encodes the current pixels with another lossy pass. The file is not guaranteed to shrink, and block edges can become easier to see because the second pass rounds an image that already contains the first pass’s error.
Is WebP always smaller than JPEG?
No. WebP’s lossy mode uses prediction plus a transform, and many photographs come out smaller than JPEG at a similar look. Flat illustration, a JPEG that was already quantized hard, or a quality number pushed to the top of the scale can make WebP larger, or only slightly smaller. The two quality scales are not one quantization table, so 80 versus 80 is not one setting. Screenshots and large flat areas are sometimes smaller as PNG, because a lossless predictor beats a lossy transform on data that repeats. The comparison that matters is the byte count of the same picture after each encode, not the name of the format.
Why did the file get larger after compression?
Decoding and encoding again does not delete bytes from the old bitstream. A JPEG is turned into pixels that already contain the previous rounding, then written with a new quantization table. That second generation can be larger than a file that was already packed tightly, and the picture is not sharper for the extra bytes. PNG saved as PNG can move either way, because the filter choice and the DEFLATE settings need not match the encoder that wrote the original. Enlarging the grid and then encoding adds samples, and more samples usually cost more bytes. A larger file is not evidence that detail was recovered.
Does a longest-edge limit crop the picture?
No. It looks only at the longer of width and height. When that side is already less than or equal to the cap, the sample grid stays as it is. When the side is longer, both axes are multiplied by the same scale so the long side lands on the cap and the other side follows. The aspect ratio holds. Corners are not cut away, and bars are not added. That is different from setting one side and leaving the other free: a long-edge cap always follows whichever side is longer. Rounding to whole pixels can leave the result one sample off the exact ratio. If the cap is larger than both sides, the grid is not scaled up.
Does a GIF stay animated after it is compressed?
An animated GIF is a sequence of frames plus a delay between them. A new encode draws the frame the decoder currently presents into the width and height being written, then stores one JPEG, PNG, or WebP. The new file has no timeline, so it does not loop. GIF transparency is a palette index, not a general alpha channel. JPEG 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. Motion belongs to the container, not to the quality number.