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