JPEG Lossless Crop & MCU Alignment Planner

Check the crop origins that JPEG lossless workflows can use. Compare covering and inside rectangles, keeping the lower-right exactly where you requested it.

FreeLocal header inspection10 worked examples
Plan the crop before changing the photograph.

Encoded pixel coordinates, explicit iMCU alignment and exact rectangle areas. This planner does not crop or re-encode an image.

Optional: read a local JPEG header

Reads at most the first 1 MiB from a JPEG up to 512 MiB, without decoding or uploading it. Successful inspection resets the crop to the full encoded raster. EXIF display rotation is not applied.

1. Set the encoded image and crop

X and Y start at the encoded top left. Image dimensions and crop sizes are positive integers up to 65500. The requested crop must fit inside the image; values are never silently clipped.

2. Compare the aligned plans

iMCU grid
Requested origin
Requested geometry
Covering geometry
Inside geometry
Extra area in covering plan
Requested area retained inside

3. Inspect the crop diagram and exact coordinates

Requested / dashed insideCovering rectangle

This is known numeric geometry, not your photograph. Dense grids are sampled to at most about 60 lines per axis; calculations still use the exact iMCU grid. Right and bottom edges do not need to lie on a grid line.

PlanXYWidthHeightRightBottomArea (pixels²)

4. Optional jpegtran command geometry

These are examples for a separate compatible installation. The planner does not run them. Replace the filenames. -copy none strips metadata and ICC profiles; a missing profile may change color appearance.

5. Save the plan

Reports retain exact crop shifts and pixel areas. With an inspected header, they also include component factors and the first scan’s parameters. These records describe header metadata and local checks, not complete JPEG validity.

Why a lossless crop can begin earlier than expected

A JPEG stores transform coefficients in blocks grouped into iMCUs. In the libjpeg-turbo crop workflow, the crop origin must sit on that grid. For a 4:2:0 image, an origin at (103, 79) misses its 16 × 16 grid. A requested 500 × 300 crop ends at (603, 379). The covering origin becomes (96, 64), producing 507 × 315 pixels and preserving every requested pixel. The inside origin becomes (112, 80), producing 491 × 299 pixels. Both plans keep the lower-right at (603, 379).

Align the origin, not every edge

Requiring the right and bottom to be multiples of an iMCU would discard or add pixels unnecessarily for this documented crop behavior. The planner deliberately leaves those two edges unchanged. Extra covering area and the area retained by the inside plan show the trade-off.

Keep encoded and displayed orientation separate

A viewer may rotate a photo using an EXIF instruction. Stored dimensions and axes can therefore differ from the displayed image. This tool reports stored header geometry. It does not infer a crop from a displayed preview. Use the EXIF Orientation & Crop Coordinate Mapper to convert a displayed rectangle into encoded coordinates and open a validated plan here.

Frequently asked questions

Does this tool actually crop a JPEG?

No. It inspects bounded JPEG marker headers and plans numeric crop rectangles. It does not decode, crop or re-encode a photograph. The SVG export is a diagram, not a cropped image. Use the geometry in compatible lossless JPEG software and check its result.

Which edges need iMCU alignment?

For the lossless crop behavior documented by libjpeg-turbo jpegtran, the upper-left origin needs iMCU alignment. The right and bottom edges do not need to align. This planner keeps your requested lower-right unchanged while moving the origin up-left for the covering plan or down-right for the inside plan.

Why can the inside crop be unavailable?

If the next aligned X origin reaches the requested right edge, or the next aligned Y origin reaches the requested bottom edge, no positive-width and positive-height inside rectangle remains. The covering plan can still preserve the full requested region.

How does subsampling affect the grid?

Typical iMCU dimensions are 8 × 8 for grayscale or 4:4:4, 16 × 8 for 4:2:2, 8 × 16 for 4:4:0 and 16 × 16 for 4:2:0. Wider or taller sampling presets and custom 8-pixel multiples up to 32 are also available. The JPEG header inspector derives a grid from supported component factors rather than guessing from the filename.

Does the JPEG inspector apply EXIF rotation?

No. Coordinates and dimensions refer to the stored encoded raster. A photo viewer may show an EXIF-rotated version with different visual axes. Work in encoded coordinates or use software that explains how orientation affects its crop input.

What does the local header inspection verify?

It reads at most the first 1 MiB of a selected JPEG no larger than 512 MiB, reports supported 8-bit DCT SOF0, SOF1 or SOF2 dimensions and sampling, and checks local first-scan spectral and approximation parameters. It does not validate entropy data, later scan history, the complete JPEG, color interpretation, or a cropping program’s eligibility rules. Unsupported or incomplete headers leave manual inputs unchanged.

What do the example jpegtran commands do with metadata?

The commands use placeholder filenames and -copy none. This strips metadata and ICC profiles; removing a profile can change color appearance. Replace the filenames and review metadata handling in your own workflow. The planner does not run the command.

What are the limits and accuracy assumptions?

The planner accepts integer image dimensions and crops from 1 to 65500 pixels, with a crop entirely inside the image. Custom iMCU sizes are 8, 16, 24 or 32 pixels. Rectangle coordinates and areas are exact integers within this range; percentages use finite JavaScript numeric precision. No rotation, trimming, EXIF remapping or complete file eligibility test is modeled.

References: libjpeg-turbo jpegtran crop behavior and TurboJPEG MCU dimensions and sampling definitions.

Related tools

Crop Image · Image Metadata Viewer & Remover · Image Converter · All image tools