Usage is straightforward:
Specify a region of the image by size and offset into the image. Negative offsets are relative to the lower and righthand sides. The resulting image will contain at least the named region (constrained to the image size), and may be larger to round up to the nearest DCT block boundary (or multiple thereof, depending on the sampling factors). If the image ends in a partial DCT block that part of the image will be lost, even though it would be possible to include it. Perhaps an enterprising reader will fix that deficiency.
jpegtran -cut WxH+X+Y
Many thanks to Guido Vollbeding for implementing the lossless rotation in jpegtran. I use it regularly to rotate digital camera images and the code framework made the addition of cropping easy. His Online JPEG Lab will let you test-drive jpegtran from the comfort of your web browser.
If you find it more convenient you can download a tarfile of the modified source files.