Jpg size bigger in CS???

DC
Posted By
Dan_Connor
Apr 21, 2005
Views
307
Replies
10
Status
Closed
I teach college computer graphics, and our history professor came to me with an interesting observation. He regularly scans in images, manipulates them and resaves. He works always as jpgs, and says he has been doing it the same way for some years. He says he does everything at a compression level of 3. This works fine for his needs.

Now that he’s in CS, when he opens an old file and resaves it, they are consistently about double the file size. How come?

MacBook Pro 16” Mockups 🔥

– in 4 materials (clay versions included)

– 12 scenes

– 48 MacBook Pro 16″ mockups

– 6000 x 4500 px

DM
Don_McCahill
Apr 21, 2005
When you save repeatedly in jpg, especially at such a low level as 3, you introduce artifacts into the file. These are small imperfections in areas of color. They do two things. a) they look bad, and b) they interrupt the compression, so that if the file is saved again as a jpg, it cannot be as small.

One should never continually resave images as jpgs. Not only will the file size get bigger (doubling sounds like a larger amount than I would expect, in a single time) but the quality will get worse and worse.

Tell your prof that he should save files in another format that does not lose data (psd is best, tiff is good if disk space will be a problem). Always work in that format, and only save to jpg when you want a small file … if you have to rework it, go back to the psd and work from that, not the jpg.

Don McCahill
L
LenHewitt
Apr 21, 2005
Dan,

Your Prof is probably saving with metadata (such as an embedded colour profile) that he didn’t previously include. He should use Save for Web to exclude metadata for smaller file size.
DC
Dan_Connor
Apr 21, 2005
Thanks Don, I knew all that. As I said, the way he is working is ok for his needs. There aren’t enough artifacts in the image to account for doubling of the file size. I inspected his before and after files quite carefully and really couldn’t detect any visible difference. Plus the fact that he insists he has done it this way forever and the file sizes don’t increase. This particular person I’m inclined to believe.

Len, Thanks I’ll look into that.
DC
Dan_Connor
Apr 21, 2005
Yeah, I just opened and resaved a series of 4 level 3 jpgs- no increase in file size at all. Save for web does give a considerably smaller file. I think thats it.
JJ
John Joslin
Apr 21, 2005
The question of saving/re-saving JPEG files has been discussed to death in this forum. A lot of non-scientific and subjective observations have come up with a lot of varying opinions.

What I have gleaned out of all the waffle and hypothesising is that:

Each time you save a JPEG it tries to compress it according to a set algorithm.

If absolutely nothing has changed in the image, and the quality setting is not altered, then a re-save should not affect the image quality.

If the slightest pixel is changed then the compression algorithm will have to be re-applied and this could result in a degradation of image quality. Also if the quality setting is changed, obviously this will have an effect on the image quality (but you can only go down and not up).

I am not familiar with the actual compression processes, so this is a layman’s take on the subject.

Having said all that, the oft-repeated mantra is right. Save your captured images as a TIFF or PSD and, having archived that, work on a copy.
C
chrisjbirchall
Apr 21, 2005
If absolutely nothing has changed in the image, and the quality setting is not altered, then a re-save should not affect the image quality.

Try this little experiment:

In preparation, have the Layer and Info palettes on screen and from the ‘View’ menu activate ‘Snap to Document Bounds’. Take an image (say) 1000 x 1500 pixels (approximately 5×3" at 300 dpi). Save it to your hard disk at maximum Jpeg Quality (12) and call it original.jpg. Reopen the file and do a ‘Save As’ – again at maximum quality. Call this one second.jpg

Now, open original.jpg, right click in the blue title bar and select ‘Duplicate’ from the fly-out menu. Drag and drop this exact copy onto the original and make sure it snaps into place. In the layers palette, change the blending mode to ‘Difference’ – and what do you see? Black. That’s because this particular blending mode will only show detail when there is a ‘difference’ between the top and bottom layers.

(Important note for the sceptics: Any detail which might be visible is due to the way photoshop renders its on-screen representation of the file. Zoom to 100% and you won’t see any!)

However, don’t rely on your eyes. Observe the Info box as you run the cursor over the image. The R G and B values will remain at Zero the whole time.

Repeat the operation, this time dragging second.jpg onto original.jpg. Once again set the blending mode as above and observe what happens now as the cursor moves over the image.

The R G B values are bouncing around between zero and two or three, proving there is a ‘difference’ between the original image and the one which has been saved and reopened.

And that is just one save operation at maximum Jpeg quality. Just imagine what happens to the detail when images are repeatedly saved – and at higher compression settings!

As John says: Save your files as TIFFs or PSDs, both of which are lossless and can be opened and closed repeatedly with out harming the image.

Only ever save as Jpeg when you are sure no further edits will be needed. For instance: on-screen display, slide shows, internet use etc, or for sending to a laboratory (at the correct size) for printing.

Chris
SF
Scott_Falkner
Apr 22, 2005
If absolutely nothing has changed in the image, and the quality setting is not altered, then a re-save should not affect the image quality.

It will, no matter how many or few (even zero) changes are made. Once a JPEG is decompressed in Photoshop it becomes the working image. Saving that file will cause Photoshop’s JPEG compression to be applied to the working image, not the image that was used to make the opened JPEG. In fact, that image no longer exists.

Also if the quality setting is changed, obviously this will have an effect on the image quality (but you can only go down and not up).

You can compress using any level you want. The higher the quality setting, the more faithfully Photoshop will store the working image, and the less degradation it will suffer.

The thing to understand it that the JPEG compression created artifacts that reduce iamge quality. When the JPEG is decompressed, those artifacts become part of the image, and will be saved with the file.

Save a file using high compression/low quality. Open it, resave using high quality/low compression. The file will be much larger. But you won’t improve the quality of hte image, just how accurately Photoshop stores it.
MD
Michael_D_Sullivan
Apr 22, 2005
It will change each time you save it, even at the maximum quality level, because the JPEG compression mechanism does not record actual pixel RGB values; it approximates them. When a file is saved to JPEG, something like the following occurs (this is a gross oversimplification): First, the RGB levels are converted to YCrCb values, because RGB values aren’t stored. Then the bitmap is broken up into segments, and each segment is assigned the amount by which its average YCrCb value differs from that of the entire bitmap; then each segment is then broken up into more segments, each of which is assigned the amount by which its average YCrCb value differs from that of its parent; etcetera, recursively, to a degree that depends on the quality level. When this file is then opened, pixel YCrCb values are created based on the averages for adjoining subsegments through the reverse of the recursion process, but you will never get exactly the same array of YCrCb values in the original. Close enough to look the same, yes. Pretty damn close, in the case of maximum quality, but not the same. And then the YCrCb values are converted to RGB, resulting in additional rounding errors.

I created a 600×900 pixel 8-bit image consisting of a radial rainbow gradient, a bunch of pencil lines in several colors, some brush strokes in black and white at various opacities, some blurring, etc. I saved it as a PSD and then as a max-quality JPEG, first.jpg <http://camsul.com/first.jpg>. I closed and then opened the first.jpg and saved it as second.jpg <http://camsul.com/second.jpg>, at max-quality. Did the same again to create third.jpg <http://camsul.com/third.jpg>.

Now I dragged a copy of second.jpg onto first.jpg and set the blend to difference. It looked solid black. I added a Threshold adjustment layer. With the threshold set to 2, representing pixels differing by 2 units, now the result <http://camsul.com/first-second-2.gif> looks like the night sky, with widely separated white pixels scattered randomly. The histogram (after refreshing the cache) tells me that out of the 540,000 pixels, 414 are white and 539,586 are black. So 99.92% of the pixels in the image are unchanged by 2 units or more, while 0.08% are changed by at least 2 units. Changing the threshold to 1, the result <http://camsul.com/first-second-1.gif> is a ghostly pattern covering virtually the whole image, except large solid-color areas, with an array of black and white dots. The histogram says 449,010, or 83.15%, are black, representing unchanged pixels, while 90,990 pixels are white, meaning they have changed by at least one unit.

Now let’s compare third.jpg to second.jpg, using the same technique. Here are the results: 1 unit <http://camsul.com/second-third-1.gif>: 477,295 black (unchanged), 88.39%; 62,705 white (changed)
2 unit <http://camsul.com/second-third-2.gif>: 539,764 black (unchanged), 99.96%; 236 white (changed)

Comparing third.jpg to first.jpg shows that the further degradation is in fact cumulative. At a threshold of 1, only 74.77% of the pixels (403,778) were unchanged, and at a threshold of 2, 99.65% (538,100) were unchanged. (I’m not going to bother posting the threshold graphics; you can recreate them if you doubt me.)

Again, this is all at maximum quality level JPEG (12). A demonstration that the cumulative differences would be much worse at lower quality levels is intuitively obvious, and is left to the reader.
JJ
John Joslin
Apr 22, 2005
Thanks for the clarification guys.
D
deebs
Apr 22, 2005
Michael – that is a wonderful, practical and pragmatic piece of work.

I wonder if the Forum hosts may be bold enough to elevate it as a ‘sticky’ (I think that is the term in some forums where one post stays near the top of the list)

I guess this answers the question in a lovely fashion

Well done!

How to Improve Photoshop Performance

Learn how to optimize Photoshop for maximum speed, troubleshoot common issues, and keep your projects organized so that you can work faster than ever before!

Related Discussion Topics

Nice and short text about related topics in discussion sections