A simple questions really. If you crop a jpeg image using the Python Imaging Library, is the resulting image recompressed, or is it lossless?
Asked
Active
Viewed 2,037 times
1 Answers
5
Generally not. There is a python wrapper for the lossless jpeg library.
Cropping might be essentially lossless if you remove entire 8x8 pixel blocks

Jason R. Coombs
- 41,115
- 10
- 83
- 93

Martin Beckett
- 94,801
- 28
- 188
- 263
-
I don't get it, doesn't the PIL library just uncompress the image when it is loaded, and store the (uncompressed) pixel values in memory? In that case any operation would be lossless, unless you save it to some compressed file format again, right? – catchmeifyoutry May 28 '10 at 23:26
-
I'm talking about going from jpeg to jpeg, so from Martin's answer it looks like I'd have to use jpegtran. – Acorn May 28 '10 at 23:42
-
3Even unpacking a jpeg into memory and recreating the jpeg isn't totally lossless, there may be rounding errors. – Martin Beckett May 29 '10 at 00:55
-
@MartinBeckett Tools that do lossless operations on JPEGS generally don't decompress them all the way; they modify the compressed representation. See: https://www.betterjpeg.com/crop.htm – Andrew Wagner Dec 18 '19 at 16:06