# This is how bad JPEG compression is: (imagesize warning)



## Garbz (Nov 20, 2007)

Those of you who have been paying attention to the Equipment subforum will know I have been bored and decided to find out once and for all how bad filtes are on lenses. http://www.thephotoforum.com/forum/showthread.php?t=100830

Well I'm extending this to another hot topic. Lots of people here talk about storing of RAW files or TIFF files (better idea IMO), or my own personal favourite Large JPEGs. I work with RAWs and PSDs and finally archive in JPEG, and in the true sense of the word they are finished files stored for long term use. I.e. I will never re-open them and edit them for anything other than making a compressed version for email or web posting.

That is me. Others however may wish to re-edit their files in the future. Some people just can't put a file down and it gets constantly played with. I thought I'd have a look at how bad lossy JPEG compression really is:

Method and assumptions:
Firstly I would like to point out I did this test with the intention to break it. The image I chose for it was a sugar glider I photographed recently. Bokeh doesn't compress well with JPEG, the slight noise makes matters worse, the image has a lot of detail in the centre, is sharp, and above all it is mostly blue. Those of you who know how JPEG works and how the eye perceives colours may also know that the blue channel suffers the worst quality hit in JPEG compression.
An action was made in photoshop which opened the file and saved it as a Quality 12 (max possible) standard JPEG. I apologise about the colour the result ended up in my working colour profile ProPhoto so the colours look entirely out of whack on a web browser, but the detail is what we are after here. Those who want to see the image with it's proper colours simply save it and open it in photoshop or another ICC profile aware software, or get a mac and use Safari.
The open and save action was repeated, a lot.

1st Save from RAW, followed by 2,3 and 4:

















At around the 5th you start noticing some of the gradients are no longer smooth:




The 10th is starting to look ugly:




The 25th shows severe compression artefacts:




Now at this point it starts getting really problematic. The compression artefacts are starting to eat into the detail on the sugar gliders coat. Image 50:




Finally 99:





Conclusion:
I started this test with JPEG at Quality 3 and Quality 5, but after seeing the full Quality 12 results there's no need to even post the others. It's known gradients don't compress well, but I was expecting more form a maximum quality JPEG after only 5 saves. It becomes unbearable at 10. If you're inclined to edit your images in the future, JPEG no matter how high quality is simply not the format for you. That said after only 1-2 saves the JPEG looks every bit as good as the RAW original.


----------



## domromer (Nov 20, 2007)

Thanks for the cool demo. If you opened and closed without making any changes you would not lose any quality right?


----------



## fido dog (Nov 20, 2007)

Thanks for the test results! I open and then save in psd to work on. I only use the jpeg for prints. 

Would this be considered "Animal Testing"???  

Cute Sugarglider....


----------



## Garbz (Nov 20, 2007)

Of course it wouldn't impact the quality if you don't save. So far there is no such thing as something which deteriorates when you only open it. Mind you the movie and record industry have been trying to do that for years... and failed every time.

The sugar glider was a reject photo. It doesn't look right bright. The photo I kept had the flash down -2EV was very dark yet looked much more natural.


----------



## Payt (Nov 20, 2007)

Thanks for sharing your findings. This is an interesting subject, as I have always wondered to what extent a jpeg deteriorates over time. 

I, too, would like to know whether the simple opening and viewing of the file causes any sort of malicious effects.

EDIT: thought so


----------



## Sw1tchFX (Nov 21, 2007)

I work everything in TIFF's. More data never hurt nobody and HD's are cheap anyway.


----------



## RKW3 (Nov 21, 2007)

Wow very interesting to say the least. So just re-saving a Jpeg image 25 times gets you worse quality?

For some reason I used to use PNG-24 to save my pictures after I photoshopped them. I never noticed a loss of quality or anything, and I realized logos and such actually come out better saved as PNG.

Since my compact camera can't save images in TIFF or RAW format, just jpeg, after I photoshop them would it be a good idea to save them as a PNG like I used to? Will that prevent compression if I feel like re-editing them multiple times?

Thanks for the test Garbz!


----------



## RKW3 (Nov 21, 2007)

First off, sorry for editing your picture Garbz, this is only for further research. (hope you don't mind)

I was curious if saving the image as a PNG-24 was a better alternate than JPEG in 100 quality, to avoid compression. Here are the results.

*Original JPEG compared to Original PNG-24* _(after being resaved off of the web only once)_
Jpeg: (still looks fine)




PNG: (still looks fine)





*JPEG compared to PNG-24 after 5 Saves*
Jpeg: (you can notice some loss of quality now)




PNG: (looks good as the first save)





*JPEG compared to PNG-24 after 10 Saves*
Jpeg: (looks pretty bad now)




PNG: (looks good as first save)





*Jpeg compared to PNG-24 after 20 Saves*
Jpeg: (looks horrible now)




PNG: (looks exactly like first save still)






I think these results prove that saving your images as PNG-24 can be a better alternate than saving your photo as a JPEG with 100 quality at times. The png still retains quality from the upload to the internet too. The only downsides I can see about saving your image as a PNG is that some photography websites/ galleries won't let you upload PNG's there, just JPEG, etc.

Overall I couldn't find a significant difference between the PNG saved ten times compared to the ones saved once. 

If any of you smarter people want to add to this or tell me if this is flawed somehow please do. This was just out of curiosity for me and I decided to share. (BTW, I'm not trying to steal your spotlight at all garbz, just trying to experiment more.) And maybe a different save type can produce the same results as the PNG too? I don't know, but for now I am going to save my photos as PNG-24.


----------



## willia4 (Nov 21, 2007)

PNG is lossless so saving it a million times won't affect its quality. 

I'm not certain (and WAY too lazy to test right now), but I bet each save will be bit-for-bit identical (until you start editing it, of course!).


----------



## RKW3 (Nov 21, 2007)

willia4 said:


> PNG is lossless so saving it a million times won't affect its quality.
> 
> I'm not certain (and WAY too lazy to test right now), but I bet each save will be bit-for-bit identical (until you start editing it, of course!).


 
That's my point. If PNG is lossless why aren't people saving their photos as that? I seem to be the only person I know of that ACTUALLY saves their photos as a PNG. (well recently I haven't been, but I have in the past for a reason I don't know, now I am going to for sure)

I know some people won't save their photos as a PNG because they have RAW or TIFF files, so I understand, but maybe some people that don't have that option should try resorting to PNG?

The only downside I have found with a PNG is that some sites/ galleries won't allow you to upload/ display them, but that's all.


----------



## [JR] (Nov 21, 2007)

I thought PNGs were for small web graphics and animations... I may be wrong.


----------



## RKW3 (Nov 21, 2007)

[JR];1035263 said:
			
		

> I thought PNGs were for small web graphics and animations... I may be wrong.


 
I believe that's what it was meant for, hence the name "Portable Network Graphics" but I believe it can have other uses. I mean if the quality comes out this good in photographs why can't they be used for this too?


----------



## Garbz (Nov 21, 2007)

The advantages of PNG is that it is lossless true, same with TIFF. I would suggest that people who re-edit old photos do so in PNG or TIFF or some other lossless format.

There are several reasons why I don't save in this format.

a) HDDs are cheap but ports on a RAID controller aren't. I would need 2 new HDDs and an Additional NAS box if I want to upgrade which is near $1000AU compared to a new $200AU HDD. At the moment I have more HDDs than computers to plug them into at the moment.
So my choice of file formats is space concious.

b) I've shown you can save JPEGs several times before the quality actually starts to deteriorate. For some people this may be sacrilege but for me it is an acceptable loss to get the file size down to a fraction of what it was previously.

c) I don't re-edit.

d) JPEGs are acceptable anywhere. If I go to show the file to someone right now I can do so with the comfort of knowing any software can open it regardless of how old. This is not the case with PNG which is only recently accepted in web browsers, and is definitely not the case with RAW which plenty of people in the beginners thread have shown to be unable to open even when looking for a way.

For me JPEG is ancient and reliable, and small. There are many better choices and if part d weren't important to me then I would probably save as a JPEG2000 which is lossy but no where near as bad as the standard JPEG.


----------



## RKW3 (Nov 21, 2007)

Garbz said:


> The advantages of PNG is that it is lossless true, same with TIFF. I would suggest that people who re-edit old photos do so in PNG or TIFF or some other lossless format.
> 
> There are several reasons why I don't save in this format.
> 
> ...


 
hmm, pretty good reasons. But for me personally, I'm going to make the switch to PNG as I find myself re-editing a LOT. 

And thank you for your original test too Garbz, now I know that re-editing is not the best idea when you save a file as a JPEG.


----------



## Bifurcator (Jun 20, 2008)

Garbz said:


> For me JPEG is ancient and reliable, and small. There are many better choices and if part d weren't important to me then I would probably save as a JPEG2000 which is lossy but no where near as bad as the standard JPEG.



JPEG 2000 has both lossy and lossless compression options. Many people in the CG industry use Jpeg2000 for use as lossless scrolling backgrounds or massive texture maps where lossy is unacceptable. JPEG2000 is probably the best pro choice for large BGs or Texture maps because the entire file doesn't need to load into memory, it's lossless, and supports 16bit, 12bit, and regular 8bit files. This makes it faster and less of a resource hog - which really matters allot when you're parallax scrolling 8 or 10 BG images of 64,000 pixels, with 10 or 20 3D objects each using 4,000 to 8,000 pixel textures. And you might be surprised actually at how common something like that is.


----------



## Garbz (Jun 20, 2008)

I've had a play with it before, and we even analysed the algorithm in one of our maths classes much to distaste of us students. It really is very good, but lacks support. 

If browsers supported JPEG2000 there wouldn't be much of an issue. Much like the lack of support for colour profiles is holding me from uploading everything in AdobeRGB the algorithm is useless if it can't be viewed.


----------



## Bifurcator (Jun 20, 2008)

Also I think you can mostly rest easy on Part D as I believe there's just about the same wide support for JPEG 2000 as there is for the old JPEG. And it's the only web displayable 16 bit format that works consistently (for me).









Lossy 16bit JPF (Jpeg2000) file compressed to 10% (AKA quality level 1 in the old Jpeg Standard).
The lossy *wavelet* compression in Jpeg2000 produces more natural looking artifacts.  
This displays great for me. Can you see it?








Lossless version in 8bit  JPF (Jpeg2000). 
This displays great for me. Can you see it?​


It would be interesting to see how many people could or couldn't see the two images above.  Please chime in and say so if you can or can not see them.


----------



## Overread (Jun 20, 2008)

I used opera, fire fox and IE7 and in all I could not see the photos at all - infact only IE7 detected them and showed the box and red X - the other 2 browsers did not show any signs of there being any photos present


----------



## ~Stella~ (Jun 20, 2008)

I cannot see the images in post 17.


----------



## Bifurcator (Jun 20, 2008)

Wow, sucks to be you guys... 







Sorry about the smarty-pants remark.  I thought it was kinda cute tho.  Anyway, shown above here is what I see.


----------



## Bifurcator (Jun 20, 2008)

Just tried it in Opera and FireFox and like you, they don't show up here either.

I wonder if there's a plug-in for browsers that can't see them?


----------



## Cubase (Jun 20, 2008)

I cannot see any images with Firefox.


----------



## Overread (Jun 20, 2008)

there might be a plug in - but as its not standard issue with the browsers its probably not finished or "official". As a result most (nearly all) people simply won't have them so to use JPEG2000 as a standarts posting format would not work.
Out of interest what are you surfing with?


----------



## Bifurcator (Jun 20, 2008)

Overread said:


> t
> Out of interest what are you surfing with?




Safari - (Free for both Mac abd PeeCee). Until last week or so it was the only browser that supported color profiles. FireFox 3 recently released, now also claims to support them.


Oh well, I guess Part D *is* still a problem then.


----------



## KD5NRH (Jun 20, 2008)

Garbz said:


> a) HDDs are cheap but ports on a RAID controller aren't. I would need 2 new HDDs and an Additional NAS box if I want to upgrade which is near $1000AU compared to a new $200AU HDD. At the moment I have more HDDs than computers to plug them into at the moment.
> So my choice of file formats is space concious.



So set up cheap old PCs as fileservers for about $200 each.  With nothing more than what's normally in them, you've got room for four IDE HDDs, or depending on the model, sometimes a lot more SCSI drives.

Organize well and you won't have to keep them all on all the time.  Better still keep jpgs of everything, and TIFF/PNG of only the stuff you haven't archived yet on your working machine and archive lossless on the servers; then you'll only need to fire one up to move files to it, or to pull the archived ones when you need to edit something.


----------



## mrodgers (Jun 20, 2008)

So, what I am gathering about this whole RAW vs. JPEG issue that we have on this forum is all about the quality loss when constantly resaving a JPEG file.

Now seriously, is there _anyone_ here who constantly edits and resaves a JPEG file?  Anyone?

I don't have TIFF or RAW saving capabilities with my camera.  All of my photos are JPEG.  Thus, the original file is saved once.

I then load it into my editor and edit.  If I want to save the edits to maybe do something later on (for resizing my edits for web, then for prints later for example) I certainly am not saving a JPEG every time I edit.  I'm not a moron and I doubt anyone who is on a photography forum is either and they would save it as a TIFF or other lossless format.  I save any edited photos as TIFF along with the resized JPEG that I use for web, email, print or whatever.

Thus, I have the original JPEG, a TIFF copy with or without edits, and a 2nd saving of JPEG for a final usable image.  The 2nd saving of JPEG may be many files as they may have been saved in different sizes or for different uses, but they are all 2nd saves coming from a TIFF file.

Is it all that difficult for everyone to understand?  I very highly doubt folks here, on a photography forum, which is 99% digital thus all about editing and saving digital images, is resaving JPEGs 25, 50, 100 times.


----------



## Mav (Jun 21, 2008)

The highest number of editing steps I ever have is 3 or 4.  Usually it's just 1, and occasionally 2.  After the 4th or 5th save on a JPEG at high quality if I zoom in at _600%_ magnification I can almost convince myself that I'm starting to see some JPEG artifacting.  I agree with the conclusion that a JPEG after 1-2 saves will look every bit as good as the RAW.  But if your editing is only going to involve that many saves in the first place (or 3 or 4) then there's still no reason to bother yourself with RAW.  Or you can just dump your JPEG files straight to TIFF if you know you're going to do a lot of editing.  Nobody in their right mind constantly re-saves JPEGs dozens of times.


----------



## KD5NRH (Jun 21, 2008)

Mav said:


> Nobody in their right mind constantly re-saves JPEGs dozens of times.



Not on a normal proof-pp-print process, but there are a few shots in my archive that I just keep thinking could be a lot better with just a *bit* more pp.  Sometimes those can get 10-15 saves before I give up, and may get even more later if I start thinking that way again.


----------



## Overread (Jun 21, 2008)

mrodgers said:


> So, what I am gathering about this whole RAW vs. JPEG issue that we have on this forum is all about the quality loss when constantly resaving a JPEG file.


 
Nope this thread is not concened with the RAWvsJEPG war as you can't save a file as a RAW 
What this thread is concerned with is the saving format of a photo after editing it - Tiff, JPEG2000 (on lossless setting) and photoshopes own save format vs JPEG which is lossy.
My own view is that I always save JPEG once I finsih editing, unless I am not totally happy with the edit - then its gets saved in photoshops own brand of file for later work. I also keep the original (either RAW or JPEG) unedited to go back to at a later date if I choose


----------



## Garbz (Jun 22, 2008)

Bifurcator said:


> FireFox 3 recently released, now also claims to support them.
> Oh well, I guess Part D *is* still a problem then.


Yes and much to my distaste Firefox disables colour management by default. I thought it was just going to be early betas but no. The gold release of 3 also disabled by default 



KD5NRH said:


> So set up cheap old PCs as fileservers for about $200 each.  With nothing more than what's normally in them, you've got room for four IDE HDDs, or depending on the model, sometimes a lot more SCSI drives.



One of the problems with revived threads is you get solutions to things which are no longer a problem. We setup a 1TB RAID1 fileserver ages ago. It just got another 1TB upgrade. 


Ultimately though this thread was to show how bad JPEG compression is for final archival. There's no doubt that it should not be used for a working file. I wouldn't suggest anything other than a lossless 16bit format, TIFF or PSD being my format of choice. The key seller for JPEG in archival is ultimately it's universal acceptance. There are a myriad of fantastic formats which mean absolutely nothing if people can't view them, and I don't wish to convert every file I want to show someone else. I had this problem a few years ago when considering using PNG files for graphics on a website only to find out IE...4 or 5 (can't remember which) didn't support them.

God willing we'll all migrate to JPEG2000 soon, but given that it's already 2008....


----------



## ilovemyD40 (Jun 22, 2008)

This is definitely an eye-opener! Also makes me want to start shooting in RAW, although I would like to research it more first. I've heard it makes editing a whole lot nicer on the photo (a problem I have experienced in the past)

Again, thanks for this post. Real interesting stuff!


----------



## Bifurcator (Jul 25, 2008)

Garbz said:


> God willing we'll all migrate to JPEG2000 soon, but given that it's already 2008....




Yup!  JPEG2000 and DNG fingers crossed.  It seems a large number of newly released cameras are doing the DNG thing so that's promising!


----------



## Joves (Jul 25, 2008)

Bifurcator said:


> Yup! JPEG2000 and DNG fingers crossed. It seems a large number of newly released cameras are doing the DNG thing so that's promising!


 My fingers are cramping from being crossed for so long. Problem is I dont see everyone going to the DNG standard for their RAW format. The best Nikon has done is putting a Tiff option in the newer cameras. But Id rather see the dng being used universally.


----------



## Garbz (Jul 27, 2008)

Adobe having somewhat of a monopoly may get the ball rolling. I didn't see a single DNG thread before the default import option for Lightroom became convert to DNG. Making people aware may be the first step.


----------



## Bifurcator (Jul 28, 2008)

Yup! 

Here's a nice info page on DNG too: http://www.barrypearson.co.uk/articles/dng/

All apps that support it, rationale, history, documentation, sample code, etc. it covers allot of ground or links to externals.


----------

