JPEG multiple saves.

vftt.org

Help Support vftt.org:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.

Neil

Well-known member
Joined
Apr 26, 2004
Messages
3,434
Reaction score
487
If I save a jpeg at 50 % quality it looks pretty bad. If I save it again but bump up the slider bar to 90% quality will I have 90% of 50% or will I get back some of what I lost in the first save?
 
You can not get back data that you have lost. Only save to JPG from the originals. Unless you are saving with no JPG compression you lose information each time you save.
 
Avoid multiple saves of jpg images, as you lose data with each save.

If you are going to save multiple times while "working" a photo it is wise to work with tiff files. This conserves the maximum amount of image data.

G.
 
Neil said:
If I save a jpeg at 50 % quality it looks pretty bad. If I save it again but bump up the slider bar to 90% quality will I have 90% of 50% or will I get back some of what I lost in the first save?
If you have an image resident in a program and save it twice at different quality levels without exiting the program and restarting, the first save should not affect the second save. (However, it depends on how the program is written--most are probably written to function as stated.)

Saving an image to a file and then reading the image from that file is different. (This what Dave and Grumpy are referring to.) Information is lost when converting to a lossy format (eg JPEG), but not when converting to a lossless format (eg TIFF). Thus it is desirable to use only lossless formats until the final result. If you must use a lossy format for intermediate files, use a very high quality (eg 95-100% for JPEG) to minimize the degradation. (For instance, if I save to JPEG directly inside my camera, I always use the highest possible quality in case I wish to process it later. If I know that I will process it later, I also save to RAW.)

For the absolute best quality, save the image to RAW in the camera, process in 16 bit formats, and save intermediate files only in 16-bit lossless formats. (TIFF includes both 8 and 16 bit formats.) Then when finished, convert to a chosen quality JPEG to reduce the file size.

BTW, the Jpegtran utility can do such things as rotate a JPEG with no additional loss by manipulating the JPEG encoded data directly rather than expanding, rotating, and re-encoding. http://en.wikipedia.org/wiki/Libjpeg

Doug
 
Last edited:
Thanks for the answers guys.

Also, when I open a jpeg (downloaded to the computer from my camera) and do something to it, even something simple like change the darkness of a section of the pic, the file size balloons. Is there a way to prevent that?
 
Neil said:
Thanks for the answers guys.

Also, when I open a jpeg (downloaded to the computer from my camera) and do something to it, even something simple like change the darkness of a section of the pic, the file size balloons. Is there a way to prevent that?

That may depend on the software you're using to do it - might be putting something in a file header...but, in general, if you manipulate the LUT's in the picture, you end up with a broader range of grey levels. Since jpg compressibility relies on similarities of values, the more values you have, the bigger the file.
 
Neil said:
Also, when I open a jpeg (downloaded to the computer from my camera) and do something to it, even something simple like change the darkness of a section of the pic, the file size balloons. Is there a way to prevent that?
What happens if you simply open the jpeg into the program and save it without modification? My guess is that the jpeg quality of the program save is higher than the jpeg quality of the save in the camera. (Of course, as noted earlier this does not improve the image--lost information will not be regained.)

You can control the size of a saved jpeg file by the quality parameter. But, as you probably know, a smaller jpeg quality also reduces the perceived quality of the image.

Note: if you write a jpeg file with quality x, exit the program, and then read the file with another program, the second program will not know what quality was used in the first program. The second program will likely have some default value that it will use when writing a jpeg file unless you override it.

Doug
 
Just for fun, set your camera to save images as RAW and download to your computer. Save the image first as a TIF, and then again as a JPG, and use 50% compression. Subtract the two images - the result will show what you've lost, and it's pretty surprising at times!
 
WinterWarlock said:
Just for fun, set your camera to save images as RAW and download to your computer. Save the image first as a TIF, and then again as a JPG, and use 50% compression. Subtract the two images - the result will show what you've lost, and it's pretty surprising at times!
Yes, but that is not how the eye works. Differences that show by this method may not be visible (or will appear different) when you view the images from the TIFF and the JPEG side-by-side.

The eye tends to be a logarithmic detector with a just-noticeable-difference (JND) of about 1% for large uniform regions over a wide range of intensities (ie changes of less than ~1% are not visible to the eye). A 1% change in a bright region is a lot larger than a 1% change in a dark region and will be far more visible in the difference picture. The JNDs are also larger in small regions or regions with detail.

JPEG was designed with the characteristics of the eye in mind and seeks to minimize the visibility of its errors in the image when presented as an image, not a simple mathematical criterion such as minimum linear error or minimum root-mean-square (RMS) error.

Doug
 
Yep - I agree. The loss is very subtle, and not noticeable unless you do multiple low res saves on top of each other.

And, unless you need quantitative info from the image, it doesn't matter. So unless Neil is looking at x-rays, jpg away!

There are lossless formats - a lossless jpg (JPG2000), and other methods like the old LZW method for TIF compression. (The latter lost popularity after Unisys sued every imaging company there was for patent violations!)
 
WinterWarlock said:
And, unless you need quantitative info from the image, it doesn't matter. So unless Neil is looking at x-rays, jpg away!
X-rays are much higher dynamic range than photos. The reason that that film X-rays are normally viewed as backlit negatives is to maximize the visible dynamic range. There are also special file formats with much higher dynamic range than JPEG that are used to store X-ray images. (Astronomical images have even more dynamic range...)

There are lossless formats - a lossless jpg (JPG2000),
There are both lossy and lossless versions of both JPEG 1991 (the one we normally use) and JPEG 2000. JPEG 1991 is based upon cosine transforms and is much cheaper to compute than JPEG 2000 which is based upon wavlets. More details at http://en.wikipedia.org/wiki/JPEG_2000.

and other methods like the old LZW method for TIF compression. (The latter lost popularity after Unisys sued every imaging company there was for patent violations!)
One can always use zip, gzip, or bzip2 to compress a TIFF file. (They use unencumbered algorithms.) I typically achieve 3:1 or 4:1 compression ratios of USGS topo maps with such compression. (Not sure what comression ratios one would expect from compressing a scenic image.) Compressing a JPEG (1991) file doesn't do much good because it is already compressed. (Compresssing an already compressed file rarely reduces the size by any significant amount.)

Doug
 
Just for kicks I spent a few minutes this morning playing with compression, to see what actually happens to file sizes. I simply grabbed a random image from one of my recent assignment files and experimented.

First, my usual workflow goes like this:

(1) Shoot in RAW format. (2) Edit shoot using Bridge. (3) Using batch functions, add basic caption material to all images. (4) Open selected image, rough crop and adjust or tweak using the Bridge controls. Image is sized at 900 dpi. (5) Save tweaked image as a JPG at quality level 12 – the maximum. (6) JPG file then becomes the primary working file for several destinations and permutations – print, remote client via e-mail, wire service, web publishing, etc.

So …

The selected RAW image started out 6.5 MB. Basic captioning adds another 8 KB in a “Sidecar” file attached to the image. Image size was 2480 x 1632 pixels.

After tweaking, cropping, and saved as a JPG at maximum quality (level 12), the file compressed to 2.6 MB. This includes the caption info now integrated with the image. Image size now is 2031 x 1532 pixels, reflecting cropping to satisfy pre-set print format proportions. Actual image size is 2.257 x 1.702 in, at 900 ppi.

Resaved the JPG “master” as a TIFF file. File size now is 9 MB.

For fun, resaved the JPG master as a JPG file at medium quality level 6. File size now is 432 KB.

For more fun, resaved at JPG quality level 4 (top of the low quality range). File size now is 336 KB.

… Cropped to 8 in wide at 72 ppi, and resaved at JPG quality level 5 (bottom of the medium quality range). This is how I would prep for web publishing or attachment to e-mail in personal correspondence. File size now is 132 KB.

… Cropped to 10 in maximum dimension (in this case, width), at 240 ppi and saved at JPG quality level 8. This is how I would prep to send on the wire or to a remote client via e-mail for newspaper publication. File size now is 712 KB.

Finally, I opened the JPG “master” and the JPG quality level 4 resaved images side-by-side. At side-by-side full image sizes on the screen there was little noticeable difference – quick observation. But when the images were blown up, quality differences soon began to appear – mostly in the form of greater pixellation in the lower quality image at any given level of magnification.

None of this is very scientific or technical, but it surely does persuade me that compressing and recompressing image files by repeatedly saving them as JPGs leads to loss in image quality. How noticeable and critical that loss actually is probably depends on how you (intend to) use your images.

Another point, here. When enlarged (magnified), the 72 ppi image saved at JPG 5 will fall apart much faster that the 900 ppi image saved at JPG 4. So there is more to this than just JPG quality level.

In any event, this reinforces the idea of preserving the original, unaltered image file (data) in an archive, and using only copies of it to produce the tweaked images for your various purposes.

G.
 
Grumpy said:
In any event, this reinforces the idea of preserving the original, unaltered image file (data) in an archive, and using only copies of it to produce the tweaked images for your various purposes.
Another reason I gotta get that new 500 Gig drive! And I thought I was rocking when I got a 750 Meg drive 12 years ago! :D
 
Top