32

Is it possible to crop a JPEG image without losing quality or recompressing the remaining part of the image?

3
  • 1
    I don't think cropping a image loses the quality of it.
    – ekclone
    Jul 7, 2015 at 11:21
  • 5
    Not in itself. However, if the image editor you are using is not smart enough, when it comes to saving the cropped image, it could easily re-compress an already compressed image, which would be needless and result in image loss. I'm wondering if it's possible avoid this. Jul 7, 2015 at 12:14
  • 1
    Could you tell me what kind of software you use? for image editing
    – ekclone
    Jul 7, 2015 at 12:56

4 Answers 4

19

Lossless cropping of a JPEG image is possible using the "jpegtran" application that comes with libjpeg; see https://en.wikipedia.org/wiki/Libjpeg.

Quoting from "man jpegtran" on a system where jpegtran is installed:

.. lossless crop is restricted by the current JPEG format: the upper left corner of the selected region must fall on an iMCU [8 or 16] boundary. If this does not hold for the given crop parameters, we silently move the upper left corner up and/or left to make it so, simultaneously increasing the region dimensions to keep the lower right crop corner unchanged. (Thus, the output image covers at least the requested region, but may cover more.)

With other image-editing software you can minimize the loss by ensuring that the cropped area has dimensions that are multiples of 8 and is located with offsets being some multiple of 8 (or 16, if the colors were subsampled) from the upper lefthand corner of the original image, and that the compression "quality" is the same as that of the original image.

7
  • The wiki says "cropping at image block borders (every 8×8 or 16×16 pixels)." Does the tool limit you to these boundaries in order to make this possible? I guess from your note about mitigating lossage in other programs that the answer is "yes" (?)
    – Yorik
    Jul 7, 2015 at 16:06
  • 1
    Sometimes the multiple must be 16 instead of 8. JPEG allows subsampling of the color information, which means the 8x8 blocks for those color components will actually cover 16x16 pixels. Jan 12, 2017 at 17:03
  • 1
    @MarkRansom right, thanks. I expanded the answer to mention "or 16" Jan 13, 2017 at 1:59
  • How do you determine if the iMCU is 8 or 16 in linux? May 15, 2017 at 20:35
  • @LuisA.Florit you could run ImageMagick's "identify -verbose" or some other JPEG examination tool and look for the "sampling factors". May 16, 2017 at 20:33
8

FreeVImager can do this with nice GUI. Lossless crop menu Lossless crop operation

It also can do lossless rotation of JPEGs (90 deg rotations are loseless). It's FOSS, so if you're on Linux, it's worth getting Wine for one.

8
  • Hmm... I tried this and the current version matches your illustration. But I can't find an "accept" or "done" control to use after moving the rectangle to the desired position.
    – JDługosz
    May 3, 2017 at 10:22
  • @JDługosz just press Enter :) (the tip in status line) Also, author is communicable and gladly responds emails. You can tell him ;-) May 5, 2017 at 21:10
  • 2
    Wow, house of my sister in Stack Exchange :) . Thanks, if I use FreeVimager, I can crop big-size jpg; if I use GIMP, I can't do it. Feb 14, 2018 at 12:50
  • This program is snapping the bottom and right sides to iMCU boundaries despite it being unnecessary and restrictive. IrfanView worked better for me.
    – mm201
    Oct 16, 2019 at 20:30
  • The cropped image is bigger in size then the original image, using the Lossless Crop toll in FreeVImager 9.9.10. So it's useless... Sep 15, 2020 at 20:58
8

Irfanview has lossless JPG cropping and rotation functions:

enter image description here

1
  • 1
    This is accessed in the menu with Options -> JPG Lossless Crop... (PlugIn).
    – Alan L
    Sep 27, 2019 at 0:29
1

If you are using Photoshop® then I don't believe that the image compresses when it crops. The compression happens when you resave the document as a JPG. It is always best to start with the highest lossless uncompressed image format you can such as .NEF, .BMP... others (?) As the saying goes, poop in poop out.

2
  • 2
    I don't think it is as you think. I think Photoshop can't do crop without recompression.
    – Royi
    Nov 2, 2019 at 18:34
  • @Royi - no. Photoshop can crop the jpeg without recompression, the problem is when you resave it as jpeg. Compression will be added again. If you export as PNG instead, you can avoid this issue entirely, since PNGs are lossless.
    – Billy Kerr
    2 days ago

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.