13

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

  • I don't think cropping a image loses the quality of it. – ekclone Jul 7 '15 at 11:21
  • 2
    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. – Dan Stevens Jul 7 '15 at 12:14
  • 1
    Could you tell me what kind of software you use? for image editing – ekclone Jul 7 '15 at 12:56
5

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.

  • 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 '17 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 ;-) – LogicDaemon May 5 '17 at 21:10
  • 1
    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 '18 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 at 20:30
9

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.

  • 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 '15 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. – Mark Ransom Jan 12 '17 at 17:03
  • 1
    @MarkRansom right, thanks. I expanded the answer to mention "or 16" – Glenn Randers-Pehrson Jan 13 '17 at 1:59
  • How do you determine if the iMCU is 8 or 16 in linux? – Luis A. Florit May 15 '17 at 20:35
  • @LuisA.Florit you could run ImageMagick's "identify -verbose" or some other JPEG examination tool and look for the "sampling factors". – Glenn Randers-Pehrson May 16 '17 at 20:33
2

Irfanview has lossless JPG cropping and rotation functions:

enter image description here

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

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.

  • I don't think it is as you think. I think Photoshop can't do crop without recompression. – Royi Nov 2 at 18:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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