Degradation of jpg when save and resaved

novetan

Senior Member
Messages
1,578
Reaction score
6
Location
SG
It has been documented save and resaved a jpg pic will progressively degrade it. But I have yet to come across any article verifying how many repeated times of save/resave before degradation set in. So out of curiosity, I did a test.

1) File size: 2800 x 2100, 4.3 mb (resolution intentionally scale down from 4000 x 3000 for conservative reason)

2) Import into CS5, save and resave the pic in jpg everytime at IQ 12

Results (all viewed at normal viewing about 400mm distance):

1) repeat 10 times – no noticeable degradation when viewed at 200%
2) repeat 20 times – slight degradation when viewed at 200%
3) repeat 30 times – substantial degradation when view at 100%

I did 2 experiments using different images and both yield about same results as above.

So I’m fairly confident to tweak on a jpg working file at least a few times whilst keeping the original. For keeper, I’ll saved as tiff anyway.

BTW, I assumed you are aware by just opening and closing (without importing into photoshop) will not affect any degradation, regardless umpteen times.
 
Thanks, that's useful info.
BTW, I assumed you are aware by just opening and closing (without importing into photoshop) will not affect any degradation, regardless umpteen times.
Actually, you can import it as often as you like without degradation. It's the saving of the file that does the damage.
 
BTW, I assumed you are aware by just opening and closing (without importing into photoshop) will not affect any degradation, regardless umpteen times.
Actually, you can import it as often as you like without degradation. It's the saving of the file that does the damage.
What's the point of importing if you don't intend to work on it?
 
BTW, I assumed you are aware by just opening and closing (without importing into photoshop) will not affect any degradation, regardless umpteen times.
Actually, you can import it as often as you like without degradation. It's the saving of the file that does the damage.
What's the point of importing if you don't intend to work on it?
Work on it, but then save it as a TIFF format rather than JPEG.

There are a couple of problems with the OP's method. First, rather than scaling the original image to half size, using a cropped section of the original would have been much better simply because scaling to a smaller size removed a huge amount of high frequency spacial detail, which is exactly would be "damaged" by saving to a JPEG format.

I generated a 42x51 pixel file containing 1 pixel wide lines in a TIFF format image; which was then saved as a JPEG, and that image was read in and then saved again as a JPEG. Then each of those images was upscaled (16x linear) to provide at 672x816 image for viewing in which each pixel is visible.

Here is the original from the TIFF file, showing nice crispy detailed lines:



Here is what it looks like after being saved to a JPEG format:



And this is what happens the first time the JPEG is resaved:



Keep in mind that when viewed as part of a 4000x3000 printed image you would not be able to see each pixel without a microscope, and the red section for instance would have just about the same appearance in the first two images, and be only slightly lower contrast in the last one.

The major significance is that 1) up scaling of a JPEG (for instance for printing) will not be as successful as down scaling (for the web), 2) it makes a great deal of difference what kind of detail is originally in the image, 3) High Pass Sharpen, and to a lesser degree Unsharp Mask, might help the looks of an up scaled JPEG image but will not restore what was lost the very first time the image was saved as a JPEG.
 
The visible degradation depends on the detail of the area. Areas with smooth gradients will degrade faster than areas where detail has good contrast.

Create a gradient in Photoshop and save it as a PSD, and then as a quality 12 JPEG. At 200% the degradation is barely visible after the second save, and obvious on the second save. After 10 saves, the degradation isn't noticeable at 100%. Saving the JPEGs at a quality of 10 is far worse. On the first save the degradation is clearly visible at 200%, and on the third save the degradation was visible at 100%.

So I would say that if your image contains any clear sky, then you don’t want to resave as a JPEG at all. Also, there really is a big difference between Photoshop quality levels 10 and 12.

.
 
You got those smeared results because you have enabled 2:2 chroma enabled which Photoshop at quality 12 does not do.

The amount of degradation depends on the compression parameters and the subject matter. But the point of visual lossy compression is to eliminate differences that are hard for the human visual system to detect.

As the OP found out, using the highest quality settings rarely produces a visual difference in itself. So in practice, you will almost never notice the difference if you only make a few small edits. However, more extreme edits may enhance the difference so as to then become visually obvious (e.g. the number of colors is reduced so a curves adjustment may result in posterization.)

--
Erik
 
So if I take a pic and my camera saves it as a JPEG I've already lost that much quality? Then when it's saved to the computer it happens again? or does it not affect it when you import to the computer?

Now if I imported a JPEG from the camera to computer and it was saved as a tiff would the results pretty much be the same as the original JPEG?
 
So if I take a pic and my camera saves it as a JPEG I've already lost that much quality?
When a camera produces a JPEG image, yes, there's a slight loss of quality, from the RAW version, that usually isn't visible when using the camera's best JPEG setting is used (such as "fine" or "high".)
Then when it's saved to the computer it happens again?
No. That's simply a transfer of a file from the camera's file system to the computer's file system. For the image to risk losing detail, you have to edit and resave the image in some image editing software such as Photoshop.
Now if I imported a JPEG from the camera to computer and it was saved as a tiff would the results pretty much be the same as the original JPEG?
Yes, you'll keep the same detail level as the original JPEG if you save and keep the image in the TIFF format.

.
 
When you take a picture and specify, in your camera, JPEG, the image saved contains less information than what was originally recorded on the sensor. And the degradation is greater if yoou choose a poorer format: "Normal" (or whatever it is called) is worse than "Fine", and this is worse than "Superfine" (or whatever). That is why RAW is preferred by many: it keeps (almost) all information, no degradation.

But when you copy the "x.jpg" file to the computer, there is no further loss. Copying is just that - making a copy.

However, if you open the file in the computer and then save it again as JPEG yes, it will be degraded. If you open it and close it again, without saving it, there will be no change.

That is what the OP has done in his test, BTW: opening and saving a number of times.
--
Antonio

http://ferrer.smugmug.com/
 
BTW, I assumed you are aware by just opening and closing (without importing into photoshop) will not affect any degradation, regardless umpteen times.
Actually, you can import it as often as you like without degradation. It's the saving of the file that does the damage.
What's the point of importing if you don't intend to work on it?
Work on it, but then save it as a TIFF format rather than JPEG.

There are a couple of problems with the OP's method. First, rather than scaling the original image to half size, using a cropped section of the original would have been much better simply because scaling to a smaller size removed a huge amount of high frequency spacial detail, which is exactly would be "damaged" by saving to a JPEG format.

I generated a 42x51 pixel file containing 1 pixel wide lines in a TIFF format image; which was then saved as a JPEG, and that image was read in and then saved again as a JPEG. Then each of those images was upscaled (16x linear) to provide at 672x816 image for viewing in which each pixel is visible.

Here is the original from the TIFF file, showing nice crispy detailed lines:



Here is what it looks like after being saved to a JPEG format:



And this is what happens the first time the JPEG is resaved:



Keep in mind that when viewed as part of a 4000x3000 printed image you would not be able to see each pixel without a microscope, and the red section for instance would have just about the same appearance in the first two images, and be only slightly lower contrast in the last one.

The major significance is that 1) up scaling of a JPEG (for instance for printing) will not be as successful as down scaling (for the web), 2) it makes a great deal of difference what kind of detail is originally in the image, 3) High Pass Sharpen, and to a lesser degree Unsharp Mask, might help the looks of an up scaled JPEG image but will not restore what was lost the very first time the image was saved as a JPEG.
Thank you for the extension test which certainly qualified as technically more efficient. Mine is simply a "layman" kind of test in normal distance viewing. If you can see it, you can see it. If you can't, then you can't without using any laboratory miroscope.

But your test certainly confirms that.
 
Ok, Thank you. I was kinda thinking that was the case but not sure.

Now I take it that you do not lose as much or very little when doing PP then saving to TIFF, is this correct?
Or if you were to save pp in tiff and then later go back and do more pp.
Sorry if this sounds slow but,,well,,ya know :)
 
And, on the other hand, you have "degradation" of image quality, as soon as it's captured using any "digital" camera. But, back to your point, with my digital cameras (all, except for iPhone), for all but the fewest of my shooting needs, shooting in digital RAW with my digital cameras, is my preferred mode of shooting -- heck, it's so quick & easy, that I simply don't understand why so many folks seem to prefer "jpg". :|

--
BRJR ....(LOL, some of us are quite satisfied as Hobbyists ..)

 
Now I take it that you do not lose as much or very little when doing PP then saving to TIFF, is this correct?
Or if you were to save pp in tiff and then later go back and do more pp.
Sorry if this sounds slow but,,well,,ya know :)
You lose nothing at all due to file format when you save intermediate edits as a normal (uncompressed) TIFF, so if you do the following:

1. Load your original camera generated JPEG into your editor,
2. Do some edits,
3. Save as a normal TIFF,
4. Load the generated intermediate TIFF file into your editor,
5. Do more edits,
6. Save or replace the TIFF file.
7. Repeat steps 4 to 5 as often as necessary.

8. Finally save your final result into any format you require for your actual use, such as a high quality JPEG.

You will have lost nothing due to the file formats except for the very last save to JPEG, and as you have shown that is imperceptible when using a high quality JPEG compression; this doesn't address any information that was originally lost in the conversion from the internal raw sensor data to the camera (or application) generated JPEG or any information you choose to eliminate in your edits, obviously.

As a matter of interest although not really of practical use, reading a JPEG that was generated by exactly the same compression algorithm and saving it back to the same format using exactly the same compression parameters and algorithm with no image edits in between should generate absolutely no changes in the image whatsoever if the compression algorithm properly compensates for differences in rounding between the reading and the writing processes . Your proof that for Adobe Photoshop CS5 that you can see degradation even for the highest quality JPEG compresion after 20 or 30 loops indicates that it does not properly compensate for differences in rounding between the reading and writing processes .

Regards, GordonBGood
 
Now I take it that you do not lose as much or very little when doing PP then saving to TIFF, is this correct?
Or if you were to save pp in tiff and then later go back and do more pp.
Well, the focus of this discussion was the loss of detail from JPEG compression, which is a compression scheme that always tosses some detail every time you resave an image. Losses from processing is a different subject. Those losses depend entirely on the process you're performing. For example, sharpening changes lots of information, but doesn't really lose detail. A black & white conversion loses all the color information of an image, but you wouldn't consider that bad. So whether a loss is bad or good depends on the process and on what's being lost.

.
 
I never resave JPEGs of edited photos knowing the degradation problem. However, recently I found out that even editing the metadata of the JPEGs (title, caption, keywords, etc) results in degradation. I notice the file size gets smaller after editing metadata. Lame.

So from now on, I'm going to save all post-processed photos as TIFF (with LZW compression) before creating a JPEG version to upload to the internet. Previously I only made a TIFF version for photos where the post-processing was complex or time-consuming, so that I didn't have to redo the post-processing. I prefer the final post-process versions of photos to be in stable files.
 
As a matter of interest although not really of practical use, reading a JPEG that was generated by exactly the same compression algorithm and saving it back to the same format using exactly the same compression parameters and algorithm with no image edits in between should generate absolutely no changes in the image whatsoever if the compression algorithm properly compensates for differences in rounding between the reading and the writing processes . Your proof that for Adobe Photoshop CS5 that you can see degradation even for the highest quality JPEG compresion after 20 or 30 loops indicates that it does not properly compensate for differences in rounding between the reading and writing processes .
Forgot about the technical jargon, sorry its a mouthful for me.

Are you saying as opposed to what I've discovered, you reckoned resaving without any edits in between and repeat it 20 to 30 times shall not see any degradation? That's what I initially thought for a couple of years until I did my own experiment (without any edits, just import into CS5 and resave) got me thinking again.

Or did I got a fake CS5?
 
I never resave JPEGs of edited photos knowing the degradation problem. However, recently I found out that even editing the metadata of the JPEGs (title, caption, keywords, etc) results in degradation. I notice the file size gets smaller after editing metadata. Lame.
Now this is bad; while editing the meta data with a proper meta data editor will require a new copy of the image to be made, there is no reason that the RGB data even has to be read let alone re-compressed, and a proper meta data editor should just be copying the RGB image data across to the new copy as a block of data. What meta data editor were you using?

Regards, GordonBGood
 
As a matter of interest although not really of practical use, reading a JPEG that was generated by exactly the same compression algorithm and saving it back to the same format using exactly the same compression parameters and algorithm with no image edits in between should generate absolutely no changes in the image whatsoever if the compression algorithm properly compensates for differences in rounding between the reading and the writing processes . Your proof that for Adobe Photoshop CS5 that you can see degradation even for the highest quality JPEG compresion after 20 or 30 loops indicates that it does not properly compensate for differences in rounding between the reading and writing processes .
Forgot about the technical jargon, sorry its a mouthful for me.

Are you saying as opposed to what I've discovered, you reckoned resaving without any edits in between and repeat it 20 to 30 times shall not see any degradation? That's what I initially thought for a couple of years until I did my own experiment (without any edits, just import into CS5 and resave) got me thinking again.

Or did I got a fake CS5?
Oh, I doubt that you got a "fake" Adobe Photoshop CS5, as even the stolen copies are still based on Adobe's code; it seems that Photoshop is not written to do self cancellation of rounding errors in reading and writing cycles of JPEG's. That is not to say that other editors do the same as Adobe and that they aren't capable of causing additional loses per cycle when absolutely no changes are made to the RGB data .

I said that this ability is of little practical use, as why would anyone read an image in and then immediately re-write it without making editing changes? Editing meta data should not require re-compression of the image data, although perhaps some meta data editors do this as per the post to this thread:

http://forums.dpreview.com/forums/readflat.asp?forum=1018&message=37936020

Regards, GordonBGood
 
Thank you all for clearing that up for me. I am well aware of the raw advantages and am starting to use it more but I still have quite a few photos in JPEG fine and I just wanted to be clear on things before I messed them up. Thanks again and sorry about the bit of a sidetrack.
 
As a matter of interest although not really of practical use, reading a JPEG that was generated by exactly the same compression algorithm and saving it back to the same format using exactly the same compression parameters and algorithm with no image edits in between should generate absolutely no changes in the image whatsoever if the compression algorithm properly compensates for differences in rounding between the reading and the writing processes .
Compression as a generic method is not necessarily precisely a reversable process. When it is, it is called "lossless", and when not it is known as "lossy". It isn't just a matter of rounding errors.

The most obvious example is quantization, where any input value within a given range is set to precisely one value in the output. There is a difference between the input value and the output value, which is known as the "quantization error" and which results in distortion of the output signal. (Quantization distortion is commonly called a noise; "distortion" indicates that it is always the same error for the same input, while noise pedantically means the amount of error is random.)

At the output it is impossible to determine what the input signal actually was (i.e., you cannot know exactly what the quantization distortion is by looking at the output signal).

Other forms of lossy compression have exactly the same characteristic. And data (JPEG or otherwise) that is compressed with a lossy algorithm can never be uncompressed without introducing distortion (and therefore necessarily can never be rewritten to be exactly the same as the original).
 

Keyboard shortcuts

Back
Top