Image Resizer - Resize, Crop and Set Size in KB

Image

Resize a photo to exact pixels, a percent or a print size, or to a size in KB between a minimum and a maximum, as JPEG, PNG or WebP. Nothing is uploaded.

Open an image

Give the size

Choose how it fits

Pick the format

The file is made in your browser from the picture as your screen shows it. A form or a site may count sizes and KB its own way: check its rules before you upload.

Formulas and sources

Each formula this calculator uses, where it comes from, and what it leaves out. "How it works" shows the same formula with your own numbers.

The other side, with the shape kept

Every mode

Height = Width × Picture H ÷ Picture W
Height
the new height in pixels
Width
the new width you type
Picture H
the picture’s own height
Picture W
the picture’s own width

Rounded to a whole pixel, at least 1. Typing the height instead gives the width the same way. A percent scales both sides: 50% of 1080 × 1350 is 540 × 675.

Source: Standard formula; no single publisher.

Pixels for a print size

Every mode

Pixels = Inches × DPI
Pixels
the width or height in pixels
Inches
the print width or height
DPI
pixels per inch; a blank field is 300

Centimeters are divided by 2.54 and millimeters by 25.4 first, and each side is rounded to a whole pixel: 35 × 45 mm at 300 DPI is 413 × 531.

Source: An inch is exactly 25.4 millimeters, NIST SP 811 [1].

Fit and Fill

Every mode

Fit scale = min(Box W ÷ W, Box H ÷ H) Fill scale = max(Box W ÷ W, Box H ÷ H)
Box W
the width you type
Box H
the height you type
W
the picture’s width
H
the picture’s height

Fit shows the whole picture at the smaller scale, centered, with white bars. Fill covers the box at the larger scale and cuts the overflow, half on each side: 1080 × 1350 into 630 × 810 is scale 0.6, keeping 1050 × 1350 of the picture and cutting 15 pixels off each side. Stretch scales each side on its own.

Source: Standard formula; no single publisher.

Each new pixel, shrinking

Every mode

New = Σ(Share × Opacity × Old) ÷ Σ(Share × Opacity)
New
a new pixel’s red, green or blue
Share
how much of an old pixel it covers
Opacity
that pixel’s opacity, 0 to 1
Old
that pixel’s red, green or blue

Every old pixel under the new one counts by the part of it covered, so a new pixel over two and a half columns weighs the half column by half. Weighting by opacity keeps a transparent pixel’s hidden color out of the edges. Its opacity is the covered pixels’ average. When either side grows, the browser’s own smoothing draws it instead.

Source: An area average, a standard method with no single publisher; weighting by opacity is this page’s choice, stated here.

DPI in the file

Every mode

Per metre = DPI ÷ 0.0254
Per metre
the PNG’s pixels per metre
DPI
the DPI you set

A JPEG stores the DPI itself, its unit set to dots per inch. A PNG stores pixels per metre, rounded: 300 DPI is 11,811. Neither changes a pixel. WebP is saved without one.

Source: The JPEG’s JFIF header from [2], the PNG’s pHYs chunk from [3]; an inch is 0.0254 metre [1].

The crop in pixels

Every mode

Crop = round(Fraction × Side)
Crop
an edge of the box in the picture’s pixels
Fraction
where the edge sits, as a share of the side
Side
the picture’s width or height

The box is kept as shares of the upright picture, so it stays on the same part whatever the turn, and each edge is rounded to a whole pixel. The size is then worked from the box, turned: a turn of 90° swaps its width and height. Turns and the mirror move whole pixels, so nothing is blurred.

Source: This page’s method, stated here; no single publisher.

Whiten the paper

Every mode

Level = (Old − Ink) ÷ (Paper − Ink) × 255
Level
a pixel’s new red, green or blue
Old
its value before
Ink
the channel’s darkest 1%
Paper
the channel’s median, less 8

Only when you tick it. Each channel on its own, from the picture’s own pixels: paper is most of a signature’s page, so its median, less 8 for the grain, turns white, and the darkest 1% black. Ink and paper stay at least 32 levels apart, so a page of paper alone turns white. Values past either end stay at 0 or 255.

Source: This page’s method, stated here; no single publisher.

The range in bytes

File Size (KB) mode

Max bytes = Max KB × 1000 Min bytes = Min KB × 1024
Max bytes
the most bytes the file may have
Max KB
the maximum you type
Min bytes
the fewest bytes it may have
Min KB
the minimum you type, if any

The stricter count at each end, so the file passes a form that counts a KB as 1,000 bytes or as 1,024: 20 to 50 KB is 20,480 to 50,000 bytes. A range too narrow for that uses 1,024 at both ends.

Source: This page’s rule, stated here; no single publisher.

The quality found

File Size (KB) mode

Quality = the highest step with Bytes ≤ Max bytes
Quality
the JPEG or WebP quality the file is saved at
Bytes
the file’s real size at a quality tried

The steps are 0.50 to 0.99 by 0.01, then 0.995 and 1, because sizes jump near the top. Each quality tried is saved and its bytes counted, about seven tries a file. The page goes no lower than 0.50: past that it offers fewer pixels. A PNG has no quality, so its one file is checked.

Source: This page’s method, stated here; no single publisher.

A size that meets the range

File Size (KB) mode

Scale ≈ √(Target bytes ÷ Bytes)
Scale
both sides of the size tried, as a share of these
Target bytes
the minimum when too small, the maximum when too large
Bytes
the file’s real size at a quality tried

A file’s bytes follow its pixel count, so the first size tried is scaled by the square root of the shortfall, both sides alike, then by steps of 5%, at most 24, up to 8,000 pixels a side. The size is offered; the file is made at it only when you choose it.

Source: This page’s method, stated here; no single publisher.

Padding to the minimum

File Size (KB) mode

Padded = Min bytes + min(512, (Max bytes − Min bytes) ÷ 8)
Padded
the padded file’s bytes
Min bytes
the fewest bytes it may have
Max bytes
the most bytes the file may have

Only when you choose Padding, and only for a JPEG. The bytes are comment blocks placed after the file’s header blocks, each at most 65,533 bytes, the first starting with a line saying it is padding. Decoders skip them, so no pixel changes, and nothing is added after the end of the image.

Source: This page’s method, stated here; the JFIF header stays first in the file, as [2] requires.

Sources

  1. National Institute of Standards and Technology. NIST Guide to the SI, Appendix B.9: Factors for units listed by kind of quantity or field of science, length and mass. Special Publication 811.
  2. International Telecommunication Union (ITU-T). Recommendation ITU-T T.871, Information technology - Digital compression and coding of continuous-tone still images: JPEG File Interchange Format (JFIF), section 10.1, JFIF file syntax: units, Hdensity and Vdensity. May 2011, with Erratum 1 of March 2013.
  3. World Wide Web Consortium (W3C). Portable Network Graphics (PNG) Specification (Third Edition), section 11.3.4.3, pHYs Physical pixel dimensions. W3C Recommendation, June 24, 2025.

What this calculator does not cover

  • Enlarging: a larger file is smoothed between the pixels the picture has; it gains no detail.
  • Very large images: past a browser’s canvas limit (16.7 megapixels on an iPhone) the image is opened smaller, and the page says so; the new size is at most 8,000 pixels a side and 16.7 megapixels.
  • WebP: Safari and the browsers on an iPhone cannot save it.
  • Animated images: only the first frame is resized.
  • Form checks: the page sets pixels, KB and format, and cannot check a face, a background, a photo’s date or a signature’s ink.
  • A KB range: quality comes in steps, so a very narrow range can fall between two of them; widen it or change the size.
  • Color profiles: the file is saved in sRGB, the colors your screen shows; a wider-gamut photo’s most vivid colors are brought inside it.

Sources checked on

How we choose sources and test the calculators: How CalcTrail calculates

Help

Quick Start Guide

  1. Open an image: Choose a file, take a photo on a phone, paste one, or drop it on the page. A drawn portrait and a signature on grey paper are there to try first.
  2. Give the size: Pick pixels, a percent, or cm, mm or inches, and type the width and height. Turn on Keep shape to type one side only.
  3. Choose how it fits: For an exact box of another shape, choose Fill to cover it, Fit to show the whole picture with white bars, or Stretch.
  4. Pick the format: JPEG for photos, with a quality from 1 to 100; PNG for flat graphics or transparency; WebP where your browser can save it.
  5. Or set a size in KB: Choose File size (KB), type the minimum and the maximum from your form, or pick a form preset, and the quality is found for you.
  6. Download: The new size, the file’s size in KB beside the original’s, and a preview appear as you type. Download saves it with a name such as portrait-630x810.jpg; after a crop, Crop only saves the crop at its own pixels.

Frequently Asked Questions

Choose pixels, turn Keep shape off, and type the width and height. The saved file has exactly those pixels. When the box is not the picture’s shape, choose Fill to cover it and cut the edges, or Fit to show the whole picture with white bars.

Last updated