Resize an image now with the image resizer.
Pixels, file size and DPI are different things
- Pixel size is the width and height of the picture in pixels, such as 4,000 x 3,000. This is what resizing changes.
- File size is how many bytes the file takes, such as 3.2 MB. It follows the pixel size, the format and the quality, but there is no fixed link. See image compression.
- DPI (dots per inch) is only a label that tells a printer how large to print the pixels. It does not change the number of pixels. A 3,000 pixel picture at 300 DPI prints 10 inches wide, and at 150 DPI it prints 20 inches wide, with the same file. Screens and most web forms ignore it.
Print size and pixels
pixels = inches x DPI pixels = millimetres / 25.4 x DPI 35 x 45 mm at 300 DPI = 413 x 531 pixels 2 x 2 inches at 300 DPI = 600 x 600 pixels
Keep the aspect ratio
The aspect ratio is width divided by height. Change only one side, or scale both by the same percentage, and the shape stays the same. Setting both sides to values with a different ratio stretches the picture. Read resize and keep the aspect ratio for the formula and for common ratios.
When you need an exact size in a different shape
| Method | What happens | Use it for |
|---|---|---|
| Fit inside | Scaled to fit in the box. No cutting, may be smaller in one direction. | Web images with a maximum size |
| Fill and crop | Fills the whole box, cuts the overflow from the centre. | Profile photos, passport photos, social posts |
| Fit with padding | Fits in the box, the rest is filled with a colour. Exact size, nothing cut. | Product photos, thumbnails of varied shapes |
| Stretch | Forced to the size. Distorts unless the shapes match. | Almost never |
Shrinking and enlarging
Making a picture smaller keeps it sharp, because the program throws away pixels it does not need. Making it larger has to invent pixels, so it cannot add detail, and large enlargements look soft. If you must enlarge, do it once, in one step, and from the original file. Resizing in several steps loses more.
Common sizes
| Use | Size |
|---|---|
| Website full width | 1,920 px wide |
| Blog or article image | 1,200 px wide |
| Instagram post | 1,080 x 1,350 px (presets) |
| YouTube thumbnail | 1,280 x 720 px (presets) |
| WhatsApp profile picture | 500 x 500 px (presets) |
| Passport photo | 35 x 45 mm = 413 x 531 px at 300 DPI (presets) |
| Product photo | 1,000 to 2,000 px (presets) |
Resize to a file size
When an upload has a limit in KB or MB, you can lower the pixel size until the file fits, which keeps the quality clean, or lower the quality and keep the pixels. This site offers both: 100 KB, 200 KB, 500 KB for resizing, and the compressor for quality first.
Resize without stretching on a web page
Resizing with CSS only changes how the picture is displayed. The browser still downloads the full file. Resize the file, and in HTML or CSS set one side and let the other be automatic:
<img src="photo.jpg" width="1200" height="900" alt="..." style="max-width:100%;height:auto">
Resize in PHP and on the command line
magick in.jpg -resize 1200x out.jpg # width 1200, keeps the ratio
magick in.jpg -resize 1080x1350^ -gravity center -extent 1080x1350 out.jpg # fill and crop
// PHP, GD: width 1200, height follows (the -1 keeps the ratio)
$im = imagecreatefromjpeg('in.jpg');
imagejpeg(imagescale($im, 1200, -1), 'out.jpg', 90);
// PHP, GD: fill and crop to exactly 1080 x 1350
$src = imagecreatefromjpeg('in.jpg');
$sw = imagesx($src); $sh = imagesy($src);
$tw = 1080; $th = 1350;
$s = max($tw / $sw, $th / $sh); // scale so the box is covered
$cw = (int) round($tw / $s); $ch = (int) round($th / $s); // part of the source that is kept
$dst = imagecreatetruecolor($tw, $th);
imagecopyresampled($dst, $src, 0, 0, (int) (($sw - $cw) / 2), (int) (($sh - $ch) / 2), $tw, $th, $cw, $ch);
imagejpeg($dst, 'out.jpg', 90);
The GD functions above are part of standard PHP on almost every shared host, so they work without installing anything.
Common mistakes
- Resizing a copy that was already resized and compressed. Work from the original.
- Entering both sides with the wrong ratio and stretching.
- Thinking that DPI changes the pixels.
- Enlarging small web images to fill a bigger space.
- Resizing in CSS and leaving a 5 MB file on the page.
Resizer pages on this site
Presets: Percentage, Keep aspect ratio. Formats: JPG, PNG, WebP, HEIC. File sizes: 100 KB, 200 KB, 500 KB. Purposes: Passport photo, Visa photo, Instagram, YouTube thumbnail, WhatsApp, Ecommerce.