Codepackr / image / Image Resizer & Target Size Compressor

Image Resizer & Target Size Compressor

Resize images to exact dimensions in pixels (px), centimeters (cm), millimeters (mm), or inches with DPI control, and compress to a strict maximum target file size (KB/MB) client-side.

Client-Side Execution & Privacy Guarantee

This utility executes 100% locally in your web browser. Your inputs, tokens, queries, and data payloads are never transmitted to any external server or backend.

Print and web workflows often demand both a precise physical or pixel size and a hard upper bound on file size. This tool resizes first, then iteratively adjusts quality until the encoded file meets the target limit.

Supported formats are PNG, JPEG, and WebP. DPI is used only when you specify a physical unit so the pixel dimensions match the intended print size. Nothing is uploaded.

Resize then compress

You set the desired width and height in pixels or in a physical unit together with a DPI value. The image is scaled with a high-quality resampling algorithm before compression begins.

After resizing, the tool encodes the image at decreasing quality levels until the byte size is at or below the target. For lossless PNG the tool may reduce color depth or switch to a lossy format if you allow it.

Units and DPI

When the unit is centimeters, millimeters, or inches the tool calculates the required pixel dimensions from the DPI you supply. A 300 DPI print image is therefore larger in pixels than a 72 DPI screen image of the same physical size.

Changing DPI after resize does not resample again; it only updates the metadata. Always set DPI before the resize step if physical size matters.

Quality versus size trade-offs

JPEG and WebP quality settings are the main levers. The search stops at the highest quality that still satisfies the size limit. If even the lowest quality exceeds the limit the tool reports the smallest size it could achieve.

Transparency is preserved for PNG and WebP. JPEG output drops the alpha channel. Large source images are processed in the browser and may be slow on low-memory devices.

When to use this tool

  • A print shop requires an image at a specific physical size and maximum file size.
  • An email or form upload has a strict kilobyte limit.
  • You need a web asset that fits a performance budget after exact dimensioning.
  • You want to experiment with DPI and quality without leaving the browser.

How to use the Image Resizer & Target Size Compressor

  1. Load a PNG, JPEG, or WebP image.
  2. Enter the target width and height and choose the unit.
  3. If using a physical unit, set the DPI.
  4. Enter the maximum file size and unit (KB or MB).
  5. Choose the output format.
  6. Start the process and download the result once the size target is met.

Worked examples

Exact pixel resize and size cap

Input
Source: 2000x1500 JPEG. Target: 800x600 px, max 100 KB, JPEG.
Output
800x600 JPEG whose encoded size is 100 KB or smaller at the highest feasible quality.

The tool resizes first, then binary-searches quality. Exact byte size depends on image content.

Physical size with DPI

Input
Source: any. Target: 10 cm x 15 cm at 300 DPI, max 500 KB, JPEG.
Output
Approximately 1181x1772 px JPEG under 500 KB.

Pixels = physical size in inches times DPI. 10 cm is about 3.94 inches.

Common mistakes and tips

  • Start with a moderate size target; extremely small limits force visible quality loss.
  • For print, prefer 300 DPI and check the final pixel dimensions before sending.
  • If the tool cannot reach the size, reduce the dimensions or switch to WebP.
  • Always keep the original; compression is lossy for JPEG and WebP.

Frequently asked questions

Can it guarantee an exact file size?

It guarantees the result is at or below the limit. Exact equality is rare because quality steps are discrete.

How is DPI used?

Only to convert physical units into pixel dimensions. It is also written into the output metadata when supported.

Does it support transparency?

Yes for PNG and WebP. JPEG output has no alpha channel.

What if the source is already smaller than the target size?

The image is still resized to the requested dimensions; compression then applies only if needed.

Is the image uploaded?

No. Resize and compression run entirely in the browser.