# 16 Bit to 8 Bit jpg



## Joseph Westrupp (Feb 6, 2011)

I suspect this is asking too much, but I'm wondering if there's any software that converts a 16 bit psd (or tif) file to an 8 bit jpg better than Photoshop does it. After editing, I have beautiful, smooth gradients in the sky in 16 bit, but Photoshop destroys them when converted to jpg (if the saturation's at a certain threshold). I could just reduce the saturation or the contrast, but, on the particular image I'm working on, I'd prefer a higher saturation _and_ a high contrast. Another solution is the addition of noise, but I'd rather not have to resort to that if I can help it.

I realize this is quite arcane, but if anyone has any ideas, I'd love to hear them.


----------



## Garbz (Feb 6, 2011)

You're doing something wrong. There's no other way to say it. If the down conversion from 16bit to 8bit gives any visible difference then somethings wrong. 

Here's a few things which you may or may not know about in photoshop that may help:
1. Only the sRGB gamut fits perfectly into 8bpp. If you are using AdobeRGB or a wider gamut you shouldn't be saving as 8bit JPEGs, plain and simple. 
2. And more critically... How are you down converting the image, and what does your image look like?
Photoshop has the ability to change settings on the fly. If you have a plain image with a single layer and you downsample from 16bit to 8bit that one layer gets converted to 8bit. 
If however you have multiple layers then each individual layer is converted to 8bit, *and the resulting calculations on the image layers revert to 8bit*. Effectively if you start with a 16bit image work it hard, and then convert to 8bit you may as well have not started with 16bit in the first place.

The two workarounds are:
1. Flatten the image before converting.
2. Use the "Save for Web and Devices" dialogue which will automatically convert the image for you when you select JPEG as the output.


----------



## KmH (Feb 6, 2011)

Any way you approach it, 8-bits can only code 256 tonal gradations per color channel.
16-bits can code 65,536 tonal gradations per color channel. 

So Photoshop is destroying nothing, it's just the math working against you, but as Garbz points out some workflow considerations can mitigate the issue.


----------



## Joseph Westrupp (Feb 6, 2011)

Garbz said:


> You're doing something wrong. There's no other way to say it. If the down conversion from 16bit to 8bit gives any visible difference then somethings wrong.
> 
> Here's a few things which you may or may not know about in photoshop that may help:
> 1. Only the sRGB gamut fits perfectly into 8bpp. If you are using AdobeRGB or a wider gamut you shouldn't be saving as 8bit JPEGs, plain and simple.
> ...


Thanks for the in depth reply, I appreciate it.

Interesting info, and some stuff there I was unaware of. However, the problem isn't on down-conversion from 16bit, it's on saving to jpg, no matter what I do up to that point.

I think this image just won't work with a jpg (without minor posterization). I'm going to use a tiff.


----------



## dnavarrojr (Feb 6, 2011)

One way to get better looking gradients when converting from 16-bit to 8-bit is to add some grain or noise to the gradient to break it up.  If you look at a smooth gradient of a sky in a photo, you'll see when zoomed in that there's noise and subtle color variations.


----------



## Joseph Westrupp (Feb 6, 2011)

dnavarrojr said:


> One way to get better looking gradients when converting from 16-bit to 8-bit is to add some grain or noise to the gradient to break it up.  If you look at a smooth gradient of a sky in a photo, you'll see when zoomed in that there's noise and subtle color variations.


Yeah, I mentioned that in my first post.


----------



## KmH (Feb 6, 2011)

Joseph Westrupp said:


> Interesting info, and some stuff there I was unaware of. However, the problem isn't on down-conversion from 16bit, it's on saving to jpg, no matter what I do up to that point.
> 
> I think this image just won't work with a jpg (without minor posterization). I'm going to use a tiff.


It will happen when going from 16-bit to 8-bit, regardless the file type you use at 8-bits.


----------



## Joseph Westrupp (Feb 6, 2011)

KmH said:


> Joseph Westrupp said:
> 
> 
> > Interesting info, and some stuff there I was unaware of. However, the problem isn't on down-conversion from 16bit, it's on saving to jpg, no matter what I do up to that point.
> ...


What will happen?


----------



## Garbz (Feb 7, 2011)

I'm at a loss. I haven't had any loss of quality related to a JPEG save at the highest quality unless it was due to repeated opening and resaving of the same file. Certainly never lost anything in the initial save.

You still have the problem saving as an 8bit TIFF?



KmH said:


> It will happen when going from 16-bit to 8-bit, regardless the file type you use at 8-bits.



Will not. 8bpp can cover the full set of displayable colours in the sRGB gamut. If it is then something went wrong in the conversion process.


----------



## Joseph Westrupp (Feb 7, 2011)

Garbz said:


> I'm at a loss. I haven't had any loss of quality related to a JPEG save at the highest quality unless it was due to repeated opening and resaving of the same file. Certainly never lost anything in the initial save.
> 
> You still have the problem saving as an 8bit TIFF?


No big deal, man--I just think the gradient is too steep for a jpg at that saturation. Bear in mind that the artefacts I'm talking about are minor, but too noticeable for me--as I mentioned, if I reduce the saturation by about 10 points, the quality becomes tolerable. 

The 8 bit TIFF file is excellent.

Seen a few of your posts on here, and they always present a thorough technical understanding of this pursuit. If you don't mind me asking, what's your background?


----------



## Garbz (Feb 8, 2011)

Wide and varied. I work as an electrical engineer at an oil refinery but did my thesis on optoelectronics and have done signal processing and and small signal electronics as a hobby. God knows where I picked up all the useless crap I know about photoshop and colour calibration 

If it's at all possible would you be able to crop the section of interest that's causing problems and post the small 8bit TIFF here so I can have a play with it? I want to see if what you're seeing is reproducible.


----------



## Joseph Westrupp (Feb 8, 2011)

Garbz said:


> Wide and varied. I work as an electrical engineer at an oil refinery but did my thesis on optoelectronics and have done signal processing and and small signal electronics as a hobby. God knows where I picked up all the useless crap I know about photoshop and colour calibration


Interesting. PhD thesis?



Garbz said:


> If it's at all possible would you be able to crop the section of interest that's causing problems and post the small 8bit TIFF here so I can have a play with it? I want to see if what you're seeing is reproducible.


No worries, man.

http://www.mediafire.com/?8j1lp6sh5icbnqh

I had to upload it to mediafire--the gallery here doesn't accept TIFFs.


----------



## Garbz (Feb 9, 2011)

Honours Thesis only unfortunately 

Anyway. I have reproduced the problem. Quite a pain too. That dark blue colour. The one thing JPEG tosses out the window is dark blues during compression. I tried playing with the hue as well and it makes a big difference. I always think back to these classic test shots:










Both of these were uploaded to photobucket, and at the time photobucket's JPEG compressor annihilated the purple one, but if you change the hue to yellow before uploading it it was almost perfect.

Anyway back to the picture in question. JPEG compression has a very broad range of possible settings and optimisations. In your case you are very right, Photoshop is trashing the JPEG even at best quality. A quick test is to save the file as a JPEG, open it, copy it as a layer on the TIF, set the blending mode to difference, then add a levels layer and set input to 0 and output to 4 effectively meaning if a pixel is 4 values off it's white vs black. 

On the left below is the Photoshop output with the best JPEG settings, on the right below is the ACDSee output with the best JPEG settings:








Now the photoshop one shows clear striations which appear as slightly visible stripes in the gradient. The ACDSee one looks like a noisy garbage. But the critical point here is that the ACDSee recompression doesn't show stripes in the gradient as the pattern isn't regular enough.

If you're hell bent on saving this file as a JPEG your best bet may be to use a different image editor. ... Or apply noise as previously mentioned. 

Ultimately though the issue has nothing to do with the transition from 16bit to 8bit.


----------

