# Why does photoshop reduce my file size after I make changes?



## ulrichsd (Sep 21, 2011)

Hello, I tried to google this one, but it only brings up pages about intentionally decreasing file size...

I am editing photos taken with my D90 on regular compression (I've since switched to fine and hope one day to switch to RAW) and the file size is about 3 MB.  Both in Photoshop Elements (older version '03 I think?) and in Windows Photo Gallery, I'll make a few changes to brightness, contrast, etc., sometimes light cropping, but even with no cropping - I save it and the file size drops to around 1.5MB

Is anyone familiar with this?  Is it compressing the image further?  In PS, when I save I made sure the resolution was set to "maximum".

Thanks,
Scott


----------



## Tomasko (Sep 21, 2011)

It isn't only about resolution, but there's a thing called "jpeg compression". It seems you have it set the way it compresses your image during save, so make sure that feature is off. (probably impossible with windows gallery, but you can surely find that in Elements)
I just don't understand why you don't use raw? You have semi-pro D90 and you're just wasting its potential this way. What's so difficult about it for you? If you don't want to play with sliders, you can use just the settings you've already set in camera and just hit one button...Convert.


----------



## Robin Usagani (Sep 21, 2011)

If you have a JPEG image and you press save as another jpeg multiple times, the quality will degrade even if you didnt make any changes and you set it to save at maximum quality each time.


----------



## KenC (Sep 21, 2011)

As proposed above, shoot RAW, and then when you convert, work with uncompressed TIFF or PSD files only, and convert to JPG only for web or to send to an outside printer.


----------



## clanthar (Sep 21, 2011)

JPEG is an aggressive compression format that achieves it's goal by discarding content. Every time you edit and re-save a JPEG as a JPEG the algorithm goes to work to do what it was created to do -- throw away more of your photo. It's job is to throw away as much of your photo as it can. Give it a second chance and it will try again and succeed.

I use a digital camera to take photos that I eventually print. As such JPEG NEVER occurs in my workflow.

If you do have to create in camera JPEG originals you should stop the JPEG damage there. Any edits that you do should be done to copies of those originals and the edited files should NEVER be re-saved as JPEGs. Those edits should be saved as TIFF or PSD or some other non-destructive format. If you need a JPEG you can create one from the non-compressed edit.

Joe


----------



## GooniesNeverSayDie11 (Sep 21, 2011)

Why not shoot RAW now? Other than taking up more card space, and slowing down frame rates and bursts on certain cameras, there really is nothing daunting about shooting RAW. You can have ACR or Lightroom presets set to your liking so that if you did need a quick on the fly JPEG with some settings tweaked ( like in-camera processing would do ) You click 1 button and save the file.  Then if you actually want to do more indepth stuff, you can skip over the auto function and manually tweak settings or open in CS5 ( or a similar program )


----------



## KmH (Sep 21, 2011)

Photoshop is not reducing the file size.

JPEG is a lossy, compressed, 8-bit depth file type, intended as a print ready file that would _not have any additional editing done to it_.

JPEG applies it's lossy, compression algorithm every time a JPEG image is *saved, or saved as* (not just opened and closed), even if no edits were done.

With JPEG set as your capture file type, when you trip the shutter on your camera the image sensor makes a Raw image data file (12 or 14-bit depth) that the camera software immediately applies the JPEG lossy, compression algorithm to. If you capture the Raw image data file the Raw file gets written directly to the memory card for conversion to an image outside the camera.

The first thing the JPEG algorithm does is discard about 80% of the color data the image sensor captured, the first big step in compressing the file size. (All of the luminance data is retained.)
Next, the JPEG algorithm converts the pixels in the image into concurrent 8x8, 8x16, or 16x16 pixels areas known as Minimum Coded Units (MCUs), to accompish even more file compression to reduce the bit depth to 8-bits.

With little, if any, input from you global, standard, pre-canned edits to contrast, saturation, and sharpening are then made based on what the camera software engineers decided would be appropriate. Of course they made those decisions long before you ever released the shutter so the edits are one-size-fits-all(few).

JPEGs have little, if any, editing headroom because they are 8-bit depth files that only retain about 20% of the original color information, and that have had the pixels converted to MCUs.

Check out this group of tutorials: Photo Editing Tutorials


----------



## ulrichsd (Sep 21, 2011)

So, I guess it is unanimous.    I rarely do more editing to my photos than slight tilt, crop, exposure or resizing.  But I guess it sounds like I should just start shooting RAW.

The reason I was asking is because I was thinking of submitting some pictures to a photo contest but they require a minimum of 3mb files and my files are currently 3mb and after editing are way below the limit.  I'll try to find a way to turn off the compression in PS.


----------



## KmH (Sep 21, 2011)

The only way you can 'turn off the compression' is to convert your unedited JPEGs to TIFF or .PSD, neither being lossy compressed file types like JPEG is.

However, you still then likely need to save them as JPEGs for upload to the contest which will reduce the file size again.


----------



## Tomasko (Sep 21, 2011)

KmH, you're wrong. I don't have Photoshop, but with Gimp it IS possible to save it without loosing any data, over and over. When you're saving a file, a dialog popups asking you the settings, one of which is Quality. If you slide that to the right (100), you'll find out, that the new file is sometimes even bigger than older jpeg. Just tried it especially for you with one of example images that came with Windows 7. 826kB (old) vs 0,99MB (new = the same, but saved under a different name). 
It's true, that jpeg is lossy file, BUT, you can decide how much. There is no fixed value... You can preserve the quality of the file when saving, so please, don't confuse other people...
Don't confuse this with converting raw files to jpeg, because that is a different story  Jpeg will never get the same data as raw, but I hope that's clear already to everyone...


----------



## KmH (Sep 21, 2011)

JPEG is lossy every time it is saved.

The Quality setting isn't eliminating data loss, but yes the file size can be controlled to an extent by using the Quality slider.


----------



## Tomasko (Sep 21, 2011)

KmH, I know the theory, but have you actually tried it? Are you just repeating the well-known stuff or have you done some research on your own? Because I did and compared the two images side by side, pixel by pixel in random spots (literally, I zoomed in as close as possible so I could see actual pixels). No change whatsoever with setting Quality at 100 in Gimp. Please, explain  I honestly want to know.


----------



## clanthar (Sep 21, 2011)

Tomasko said:


> KmH, I know the theory, but have you actually tried it? Are you just repeating the well-known stuff or have you done some research on your own? Because I did and compared the two images side by side, pixel by pixel in random spots (literally, I zoomed in as close as possible so I could see actual pixels). No change whatsoever with setting Quality at 100 in Gimp. Please, explain  I honestly want to know.



Did you make an edit change to the photo between saves? I believe the issue is reapplying the JPEG algorithm to a JPEG file between edits. If you have the JPEG quality set to the highest value you may not end up with a smaller file then after an edit. That doesn't mean the algorithm won't have done other damage as it re-scans the image. I just ran a quick and by no means thorough test. I took a TIFF file and reduced it to 1280 pixels wide. I saved it as a JPEG in Photoshop (max quality) and it came out as 916kb. I edited it and re-saved it 4 times and it went down to 842kb and on the 5th edit and re-save it went back up to 860kb.

I'm not going to keep it up, but I'd say this isn't a positive process for this photo.

Joe


----------



## Tomasko (Sep 21, 2011)

clanthar said:


> Tomasko said:
> 
> 
> > KmH, I know the theory, but have you actually tried it? Are you just repeating the well-known stuff or have you done some research on your own? Because I did and compared the two images side by side, pixel by pixel in random spots (literally, I zoomed in as close as possible so I could see actual pixels). No change whatsoever with setting Quality at 100 in Gimp. Please, explain  I honestly want to know.
> ...


I didn't edit the image. I took an image and saved it as a new file (dialog Save as...). Then I closed Gimp, reopened the new file and saved it as the same file (through the dialog Save as..., not Save...). In theory, that should have compressed the image twice = the file should have been smaller, but it was the opposite - it was actually bigger than the original. Pixels themselves remained the same and the image looks exactly the same even at biggest zoom.
I'll try the same approach with some editing and post the results later if anyone is interested...


----------



## GooniesNeverSayDie11 (Sep 21, 2011)

Tomasko said:


> It's true, that jpeg is lossy file.


 Which contradicts the point that you are trying to make.  Unless, of course, you do not understand what LOSSY means.


----------



## Tomasko (Sep 21, 2011)

GooniesNeverSayDie11 said:


> Tomasko said:
> 
> 
> > It's true, that jpeg is lossy file.
> ...


Don't play smart ass against a guy who works in IT and try to explain what actually happens with the image using the settings I've posted...


----------



## GooniesNeverSayDie11 (Sep 21, 2011)

OHHHHHH, I forgot, IT guys are one step shy of being Steven Hawking. Pretty pompous to brag on your IT status like you are some kind of genius. Nothing smart ass about it, it was you who started spouting off and accusing people of being wrong. I just merely pointed out your contradiction. You agree that JPEG is lossy, yet argue that it doesn't lose quality when compressed ( saved ). Now, I am not "IT GUY" but that sounds sort of like a contradiction.


----------



## Tomasko (Sep 21, 2011)

In other words, you don't have anything to say but to argue about one word? Good one, now you can happily return under your bridge  You didn't say anything new and you obviously DON'T understand what actually happens, nor you're willing to try it yourself and at least attempt to explain, WHY it doesn't act the way anyone would expect.


----------



## GooniesNeverSayDie11 (Sep 21, 2011)

My guess is that the compression method was changed. See Below. Perhaps instead of pretending to be a genius, you should hit the books, before they outsource your job to India :thumbup:



The progressive mode allows the DC components to be sent first, followed by the DCT coefficients in a low- frequency to high-frequency order. This enables the decoder to reproduce a low quality version of the image quickly, before successive (higher frequency) coefficients and received and decoded. The image data can be organised into two or more 'strips' of DCT information, resulting in two or more possible preview images.








Figure 8. Two step progressive JPEG decoding.
The principle advantage of this mode is the ability to quickly view a low quality version of the image. The Disadvantages are:

The file size of images JPEG encoded this way are slightly increased.
The decoder requires a buffer for all the partial (and final) DCT coefficients.
The decoder has to recompute and display the final image every time it receives a new strip of DCT information.


----------



## GooniesNeverSayDie11 (Sep 21, 2011)

In the words of Kelso........"BURRRRRNN!"


I should add, that I am not seriously trying to insult your or anything, although the "IT" comment did come off a little snobbish. Just busting your stones a little. ( not sure if that term translates well to Slovakia )


----------



## Overread (Sep 21, 2011)

*in the words of moderator* Keep it civil darn it!


----------



## KmH (Sep 21, 2011)

Tomasko said:


> GooniesNeverSayDie11 said:
> 
> 
> > Tomasko said:
> ...


The thread was about Photoshop. GIMP, isn't Photoshop.

GIMP was/is not germain to the discussion.

I did some more checking into how Photoshop (not GIMP) applies the Quality setting.

Even at the highest setting, 12, there is some file compression. Certainly there is considerably more compression at the lowest setting of 0.

However, I was unaware that unlike most other applications the JPEG compressor Photoshop uses is convergent, such that repeatedly opening and saving the same JPEG without modifying the pixels, the data loss diminishes with each save such that eventually there is little or no data loss.


----------



## GooniesNeverSayDie11 (Sep 21, 2011)

No worries, Guvna.  Keeping it Civil with a capital "C".  (what happened to the cheese grin emoticon? )


----------



## clanthar (Sep 21, 2011)

KmH said:


> Tomasko said:
> 
> 
> > GooniesNeverSayDie11 said:
> ...



I believe the whole key here is as Keith is saying "modifying the pixels." There's no reason to run a Save As operation on an unaltered file. And once you've done something like make a Levels adjustment or color balance adjustment the JPEG algorithm is going to go back after that file in a save operation. I think it's a fair bet then that JPEG is going to do more harm regardless of the quality setting. That has been my experience. I've never know JPEG to improve a photo.

Joe


----------



## manaheim (Sep 21, 2011)

ulrichsd said:


> So, I guess it is unanimous.  I rarely do more editing to my photos than slight tilt, crop, exposure or resizing. But I guess it sounds like I should just start shooting RAW.
> 
> The reason I was asking is because I was thinking of submitting some pictures to a photo contest but they require a minimum of 3mb files and my files are currently 3mb and after editing are way below the limit. I'll try to find a way to turn off the compression in PS.



Careful.  RAW is a pandora's box.  Very valuable, and I never shoot in anything else really... but it's a LOT to take on.  Perhaps an interim step might be shooting or at least saving your files as TIFF.  (shooting in TIFF would be better than just saving in them)

TIFF is a non-lossy compression algorythm.


----------



## marmots (Sep 21, 2011)

Tomasko said:


> but have you actually tried it



ok i just tried it

i made a macro for my computer, and did exactly what you did, only 500 times more

it took a 15mb file to an under 1mb file


----------



## shmne (Sep 21, 2011)

Facts are facts.

Jpegs are lossy. Period. There is no argument about this. 
If you have any understanding of how file compression works then you would not be trying to argue this fact. Let me explain since there is a clear misunderstanding going on.

If you slide the quality slider to 100% guess what is happening? There is an algorithm being applied that does NOTHING. That is why you are finding out that your file size is larger with no difference. There is a second layer of compression embedded into the file that ends up beefing up the size without changing the file. 

This is the difference between professional software and freeware. Photoshop would never allow this because it is completely useless, potentially harms the image, and in the end will increase file size. Also do note that "max" on photoshop jpeg compression appears to be 10, but actually is 12. 

Saving a jpg, as jpg is very hazardous to your file's health and may cause banding as well as artifacting.

Again this is not opinion, this is fact. If you have questions about compression please consult google about compression, there are very lengthy articles I am sure. My knowledge comes from my teacher in college who helped develop algorithms for compression. I trust his explanation of how things work quite a bit


----------



## manaheim (Sep 21, 2011)

I can't believe anyone is seriously debating this point. 

I swear some people just like to shout at the rain.


----------



## clanthar (Sep 21, 2011)

shmne said:


> If you slide the quality slider to 100% guess what is happening? There is an algorithm being applied that does NOTHING. That is why you are finding out that your file size is larger with no difference.



This is incredible! The algorithm does nothing and yet the file size is  larger and yet there is no difference. I'm going to meditate on that. Maybe if I got stoned?



shmne said:


> There is a second layer of compression embedded into the file that ends up beefing up the size without changing the file.



Sneaky! Change the file without changing the file, of course! Why couldn't I see it! JPEG was created by Congressional economists!!



shmne said:


> Also do note that "max" on photoshop jpeg compression appears to be 10, but actually is 12.



I know! That has always bothered me. When I pull the JPEG slider in Photoshop to the far right end it says 12 but it appears like a 10! How do they do that?!!!

Joe


----------



## shmne (Sep 22, 2011)

clanthar said:


> shmne said:
> 
> 
> > If you slide the quality slider to 100% guess what is happening? There is an algorithm being applied that does NOTHING. That is why you are finding out that your file size is larger with no difference.
> ...



Actually you're right it isn't Photoshop that does that, it is Adobe Camera Raw :




It says 10 is the max, but really 12 is. Sorry I don't save in lossy formats normally so I couldn't remember which application it was.

Alright I don't know if you're trolling or if you just completely missed what I sought to simplify and explain in an easy to absorb manner. What I explained is completely correct, there is much more detail than what I stated but what I stated is true. My lecture notes take about 30 minutes to go through, and it is not something I look forward to typing out to an audience that will not understand a vast majority of it.

Jpg is math. Math takes work. Work adds file size. 

[ JPEG ] - this jpg compression takes up 1mb to be applied to an image, but it drops a 10mb file down to 200kb. 
[ JPEG ] - This is the same compression. It still takes up 1mb. The computer must still run it. This also drops a 10mb file down to 200kb, however since there is an already existing jpeg compression it just takes what the previous one does and repeats it.

The file is now 2mb and 200kb instead of just being 1mb and 200 kb. 

Another way to visual this:

{Jpeg  [ File ] } 
{Jpeg {Jpeg [ File ] }} 

Which is bigger ? If you answered the bottom one, you're right! Congrats.

So to recap, 1+1 = 2.
2 > 1.
Therefore, the more you add, the more you have!  I'm so glad we had this discussion. Thanks :3


----------



## Tomasko (Sep 22, 2011)

shmne said:


> Facts are facts.
> If you slide the quality slider to 100% guess what is happening? There is an algorithm being applied that does NOTHING. That is why you are finding out that your file size is larger with no difference. There is a second layer of compression embedded into the file that ends up beefing up the size without changing the file.
> 
> This is the difference between professional software and freeware. Photoshop would never allow this because it is completely useless, potentially harms the image, and in the end will increase file size. Also do note that "max" on photoshop jpeg compression appears to be 10, but actually is 12.


Finally some interesting response. However, I fail to understand one thing - you're saying, that nothing happens, adding some second layer in the same time that is invisible and useless, while there's no change in the file, no pixels altered, yet you claim, that it is potentially dangerous? How's that? 



			
				GooniesNeverSayDie11 said:
			
		

> I should add, that I am not seriously trying to insult your or anything, although the "IT" comment did come off a little snobbish. Just busting your stones a little. ( not sure if that term translates well to Slovakia )


That IT thing I've mentioned was because I don't need lectures on what "lossy" means, nor about file types. Nothing snobbish meant by this, but I understand it maybe didn't leave the right impression. Sorry about that


----------



## ulrichsd (Sep 22, 2011)

KmH said:


> Even at the highest setting, 12, there is some file compression. Certainly there is considerably more compression at the lowest setting of 0.



Ok, I played with it some more last night, and this was my problem.  PS defaults to setting 10, I didn't notice it went up to 12.  If I set it at 12 and do the pass mode 5 layers (not really sure what that is), it actually slightly increases the file size.

Thanks again for the info and the debate.  And thanks mod for not locking this thread prematurely!
Scott


----------



## clanthar (Sep 22, 2011)

shmne said:


> What I explained is completely correct, there is much more detail than what I stated but what I stated is true. My lecture notes take about 30 minutes to go through, and it is not something I look forward to typing out to an audience that will not understand a vast majority of it.
> 
> Jpg is math. Math takes work. Work adds file size.
> 
> ...



And I am so glad you were willing to take the time, given so many of us have a limited capacity to understand. I just hope you'll be willing to do one more thing and explain why an empirical test of what you've described fails to produce the expected result.

I opened a TIFF file in Photoshop. The original came from a RAW file and had never before been compressed.

I sized the photo to 2048 pixels wide and saved it as a JPEG with Photoshop's quality slider set to 12 (max).

I named the file jpeg_test1.jpg. Thanks to you I now know I have {Jpeg  [ File ] } and the file size is 2,076,337. See for yourself:








I opened up the file jpeg_test1.jpg in Photoshop and saved it with a different name using the File SaveAs operation. I created jpeg_test2.jpg (JPEG slider still at 12). According to you I now have {Jpeg {Jpeg [ File ] }} and therefore my jpeg_test2.jpg file must be bloated by a second JPEG and since the previous JPEG was already there the math just repeated itself. And that explains why my second file is larger by a negative 44,945 bytes. See for yourself:







I don't think this is true: -44,945 > 0. Could you have missed something in those notes?

Joe


----------



## shmne (Sep 22, 2011)

This is a close up of the bellow:






Here is the full file so you can see that the one on the left is created first, then the one on the right.





Yeah the second file looks smaller to me alright... all 6,949 bites larger. Opened photo... saved as jpeg... saved jpeg as jpeg... ended up slightly larger. Just like I said it would. 

I have no clue what you're doing, but if you open a jpeg and save it as jpeg with identical settings (if you drop the quality at all, it will get smaller. Even if opened by a different application as not all programs save jpegs the same way), the new jpeg will be LARGER than the old one. I can do these examples all day long on hundreds of machines... anytime you stack compression you risk quality and gain size. (The risk of quality loss comes from opening several jpeg compressions) This is not coming from me, this is accepted industry knowledge. Go ask any graphic designer, video editor, or audio tech. 

If you still doubt me I could show you a video of how this happens.

Edit**
Also since you are seeing that large of a drop off that is telling me you compressed the file further. A 44k drop is steep, if your compression worked fully it can never get smaller on the same settings. Again go search on your own, I'm not making this up. If you knew anything about how compression works then you would understand how you can't possibly be right.


----------



## clanthar (Sep 22, 2011)

shmne said:


> ...anytime you stack compression you lose quality and gain size.



Not according to you! And I quote you:

"There is an algorithm being applied that does NOTHING."

Losing quality isn't NOTHING it's something.

And I quote you:

"...however since there is an already existing jpeg compression it just takes what the previous one does and repeats it."

Losing quality is not repetition. If you repeat something it's the same.

Joe


----------



## shmne (Sep 22, 2011)

Tomasko said:


> shmne said:
> 
> 
> > Facts are facts.
> ...



The danger of it comes from repetition. If our computers were made by flawless machines then I'd say there is no risk, just larger file sizes. The fact is though ghosting happens. (Ghosting is where code does not always behave the same way every time).

Imagine this: 
You are asked to paint a picture.
Now you are asked to paint the same picture again, identical to the first that will replace the first so it must be identical. Pretty difficult isn't it?

Granted people have a much harder time doing this than machines, which are created for the purpose of repetitive tasks. 
Machines are great at repeating themselves, but like us they are not always perfect. Ghosting occurs in code that makes it behave differently then planned. So if you have a Jpeg { Jpeg [ File ] } Sandwich, what inevitably happens is artifacting that was not present originally. This doesn't have to happen, but it may. hence the "risk" of multiple compressions. Honestly will an amateur even notice? No way, I'd be amazed if anyone without a trained eye could take notice. So it isn't the end of the world, just a "best practice" sort of mindset.  

Artifacts in jpegs can be anything from banding, to a pixel becoming the wrong color, to entire color shifts. 

I do apologize as I was speaking out of term as photoshop allows you to re-apply jpeg compression as many times as you want. When I said "This is the difference between professional software and freeware..."  I started saying one thing, and ended another. What I was trying to say is that programs like photoshop offer high quality compression that will not make you want to re-apply compression because in doing so does not increase quality but put it at risk. What I did say however couldn't be further from the truth as you can save files over and over again to stack multiple jpeg compressions (but again this just bloats the file as once compression is applied if no settings are changed it will always get larger.)

The increased file size comes from adding a second operation onto what should have only been one. The potential quality loss comes from the decompressor doing 2x the work.
I think what is hard to understand is what compression actually does. It is a mathematical formula that shrinks an image by a random but constant (for that image) factor. Once neatly grouped up into pixel quads, the compressor should always compress the image the same way time and time again. Thus never shrinking the file. 

I got another good example! Just thought of it now  Ok. Stay with me on this one, it may be a bit of a jump but I think it works:

Think of a compressor as a puzzle maker! It takes the file and makes it into a puzzle that must be re-assembled by another program at a later time. Say a quality 12 compression breaks an image into 100 puzzle pieces. If you add another quality 12 compression, it pretends like there was no previous compression so it starts with the full picture again and re-compresses the same exact way. Just like a puzzle is unique and can only be assembled one way. This is where the risk is involved, because if there is one miscalculation in the decimal places it can make a wide variety of artifact appear.


----------



## shmne (Sep 22, 2011)

clanthar said:


> shmne said:
> 
> 
> > ...anytime you stack compression you lose quality and gain size.
> ...



Repetition is not perfect, not even on computers. Try to nit-pick me all day, it doesn't matter; I know I'm right lol. You do risk losing quality, but the risk is extremely negligible. As a professional I would never put a client's work at risk like that, but for an amateur? The risk is so tiny it would be fruitless to worry about  the artifacts that could occur, instead it would be better to just not make the mistake of double-compressing in the first place.

Please research more about your subject material before trying to attack someone that actually has an understanding of the subject. I don't mind defending my posts, and I do admit I make mistakes quite often. I couldn't be farther from perfect. Depending on the level of the people I'm speaking to I alter the material, if someone is struggling with a concept I'm not going to come at them with "When you stack compression, you gain size and run the risk of causing ghosting that can lead to an error in the de-compressor which causes an artifact in your jpeg, thus lowering its quality."

No, instead I'm going to explain it on their level.

The de-compressor must open every jpeg compression, so you're absolutely right it; adding a second compression doesn't do "nothing." You're just taking my words out of context, my use of the word "nothing" was intended as "The second compression does not compress the file more." Hence "There is an algorithm being applied that does NOTHING." 

The secondary algorithm does not compress it further, it just repeats what the first did. Giving the computer a second chance to mess up an already difficult procedure. Jpeg may be a wonderfully fast loading file, but keep in mind that all compression is difficult and offers many opportunities for a computer to make a mistake.


----------



## ulrichsd (Sep 22, 2011)

shmne said:


> ...anytime you stack compression you lose quality and gain size.



Quick question, could someone explain what stack compression is?  I think there is this option when I save, with a value of 1 through 5.

When I save in PS on 12 and click stack compression at 5, my file size does get larger.  Is stack compression good or no?  Is there a time to use this?


----------



## shmne (Sep 22, 2011)

ulrichsd said:


> shmne said:
> 
> 
> > ...anytime you stack compression you lose quality and gain size.
> ...



I believe you are referring to progressive scan - 5? 

The way this format works is the following:
There are 5 scans of the jpeg in one file. These range from poor quality, to full quality. The use for this is that when you view it you get an immediate result, of terrible quality. The longer you wait the better the quality becomes. Each scan of the 5, builds upon the previous versions. So the first scan is aweful but also very tiny. The final scan is your quality setting.

It gets bigger because you are choosing 5 (3 is probably all you would want for most files) then also putting the quality allllll the way up. Generally with this type of compression the end goal is web. It allows them to see an immediate result, then slowly increase the quality as the page loads. This is a web setting, more than a "keep it on my computer" setting. This type really shines (in my opinion) with 3 scans at a quality of 8. 

Your size is most likely increasing because you are working with a jpeg file, then saving as a higher quality jpeg. As stated previously by KmH if you save a file in photoshop that is identical to the start, little compression if any is used so instead of shrinking the file; it expands. 

The compression itself is comparable to the size of baseline jpeg - I don't want you to think that there are 5 jpegs in one file, just that by setting it to 5 there is more of a "squish" effect going on. This type of jpeg has not seen much use until recently with the web.


----------



## Tomasko (Sep 22, 2011)

shmne said:


> The danger of it comes from repetition. If our computers were made by flawless machines then I'd say there is no risk, just larger file sizes. The fact is though ghosting happens. (Ghosting is where code does not always behave the same way every time).
> 
> Imagine this:
> You are asked to paint a picture.
> ...


Thank you for your time.


----------



## shmne (Sep 22, 2011)

That example is a little off actually, with the puzzle at the end. I'm just having trouble relating it to something real and tangible. I'm unsure if the second compression ignores the first, or works with it. However from what I've seen with all types of compression is that if you apply identical compression it enlarges, which I must assume is because it is just repeating what the first already figured out.


----------



## manaheim (Sep 22, 2011)

It's interesting that Photoshop seems to increase the file size on the image after each save... in my testing of CS5... with no edits... it adds about 4K per save. However, I'm not sure that this is really the point, nor do I believe it is anything of any noteworthy consequence other than a virtual stick you can use to beat down anyone who might suggest otherwise.

First off, what does the file size mean?

It means only one thing: the file is bigger. For all we know, Photoshop could be storing some additional padding as part of their compression algorithm, or it is making a different decision here or there that is just winding up with a slightly different file size. This is not unheard of in compression.

Second, keep in mind what the compression alg is doing here. This isn't ZIP, and these aren't word documents. This is an image. There is a LOT of leeway afforded to an algorithm that is able to toss stuff in the trash without us knowing, and that's exactly what it is able to do. Toss a few bytes out in a word document and it may not work... or at best it's going to have some missing letters. Toss out a few bytes of visible data out from an image, and you may get a variation in a color of a pixel here and there. Almost nobody is going to notice that. However, do it enough times... and you might start to notice.


The thing that irks me about this entire conversation is you have several experienced people on here who are telling you that JPEG quality is lost in each new save, and some of you are whipping out the growing file size as some sort of ridiculous straw man to show how amazingly wrong we are.

Fine, let's dance.

Here is what I did...

I took one of my images and took a 100% crop image of the image and saved it at max quality in Photoshop CS4 64 bit.(level 12).  I then opened each progressive saved copy of the file and then saved it with an incremented number.  I did this 20 times.

As you can see, the file sizes did increase with each save.






Here is the FIRST save of the file.






Here is the TWENTIETH save of the file.






Now it's a little hard to tell here, but what I recommend is that you save these off to your desktop and then open them both in an image viewer and flip back and forth between them.  If you watch, you'll notice something.  In some places in the image... the image CHANGED.

I highlighted a couple of the general areas here in this image so you can know where to look if you didn't happen to catch it.






Now, are those changes earth shattering?  Well... not overly... but _*they are changes*_, and that is the key bit.  Every time you save off that file you risk a different re-interpretation of your image, which can have impacts on the quality of your image.

*Period*.


----------



## ulrichsd (Sep 22, 2011)

shmne said:


> I believe you are referring to progressive scan - 5?
> 
> The way this format works is the following:
> There are 5 scans of the jpeg in one file. These range from poor quality, to full quality. The use for this is that when you view it you get an immediate result, of terrible quality. The longer you wait the better the quality becomes. Each scan of the 5, builds upon the previous versions. So the first scan is aweful but also very tiny. The final scan is your quality setting.
> ...



Thanks so much for the info, makes sense...


----------



## clanthar (Sep 22, 2011)

shmne said:


> That example is a little off actually, with the puzzle at the end. I'm just having trouble relating it to something real and tangible. I'm unsure if the second compression ignores the first, or works with it. However from what I've seen with all types of compression is that if you apply identical compression it enlarges, which I must assume is because it is just repeating what the first already figured out.



Now we're making some progress. You "must assume" is a lot better than dictating facts. I reacted to your first post and so as not to take you out of context:



shmne said:


> "Facts are facts.
> 
> Jpegs are lossy. Period. There is no argument about this.
> If you have any understanding of how file compression works then you  would not be trying to argue this fact. Let me explain since there is a  clear misunderstanding going on.
> ...



And yes you did say the algorithm did NOTHING and you reinforced that by saying it didn't change the file. And we know that's wrong and yet we can understand what you actually meant (but didn't say).

I reacted to the arrogance and nonsense of your first post with sarcasm. I shouldn't have and I'm sorry.

In the example that I posted where the file shrank I used Photoshop CS4 and I most certainly did not alter the JPEG settings in any way. I did make a slight (visually imperceptible to most people) change in the file. I opened the Hue/Saturation dialog and lowered the saturation from 0 to -2 because that's what this whole thread was about!

And yes that was enough of a change to cause Photoshop to re-do the compression and shrink the file.

It is complete nonsense to open a file and re-save it without first altering it. Why would anyone ever want to do that? That's just dumb. This thread was about "Why does photoshop reduce my file size after I make changes?"

And the JPEG algorithm does do that. If you make even slight changes to the file content the JPEG algorithm will re-process the file.

You must have assumed people thought that compression applied to a compressed file would further compress the file. That wasn't what this thread was about.

You jumped in and dictated as gospel truth what would happen if someone did something that is utterly dumb and completely useless. Now you're "assuming" and it looks like manaheim has demonstrated that you're wrong.

Sorry for the sarcasm. I have to run to class now -- and how about that, it's a class in Photoshop.

Joe


----------



## clanthar (Sep 22, 2011)

manaheim said:


> Here is what I did...
> 
> I took one of my images and took a 100% crop image of the image and saved it at max quality in Photoshop CS4 64 bit.(level 12).  I then opened each progressive saved copy of the file and then saved it with an incremented number.  I did this 20 times.......
> 
> ...



Nice job with the example.

This whole thing got somewhat out of hand and I'm guilty because I reacted poorly to shmne's first post. I think we all really pretty much agree and understand.

1. JPEG is a compression methodology that alters your file content and as such does damage.
2. You can't compress compressed. I think this is what shmne tried to say. If you re-apply JPEG level 10 compression to JPEG level 10 compression you're not going to get more compression.
3. Alter a file (Levels change, color change, etc.) and JPEG will re-process the file and that re-processing will do additional harm.
4. JPEG can never improve a photo. JPEG can only remove content and/or add noise (artifacts).
5. As you've shown, iterative JPEG without editing in between does alter the file and does do further damage. I believe shmne is fundamentally correct in this regard; slight variation in the run of the algorithm is at fault. I would assume over time the process is entropic.

Now I really have to run to class.

Joe


----------

