JPG to DNG or scene-referred editing of older images

I have come to love the processing available in darktable and I have images that are JPG that I would like to manage and edit within DT. I found that converting a JPG to PNG would then be recognized by DT, but the processing is not scene-referred.

Looking for ways to convert to DNG, I find

  • Topaz labs has a pricey solution
  • online conversion which I would like to avoid for several reasons

Any other approaches that people know of?



You can’t improve the jpg just edit that …conversion won’t gain you anything…No matter what you do you have 8 bits of data to work with…you can’t scene edit a jpg the scene referred data is long gone…

I agree with @priort. A JPEG is only 8 bits per channel, and probably lossy-compressed. Only limited processing is possible before the data loss becomes obvious.

JPEG is an output-only format. Great for distributing the final version of an image, and lousy for anything else.

Of course, if you really want to, you could convert a JPEG image into some other format, such as a DNG. You could undo the sRGB transfer function to make it linear (kind-of, sort of). Some software claims to undo lossy JPEG artifacts.

And some software may exist that “invents” data to make the pixels 16 bits per channel. I would be surprised if that software didn’t exist. But I don’t know if it would be any good.

I did not understand this either…jpgs are recognized perfectly by DT without any conversion…perhaps that is not what you meant??

I suspect he is referring to this product… JPEG to RAW AI – Topaz Labs

I like how they are trying to portray a raw as being confined to Adobe RGB and the jpg can magically be better than the raw in Prophoto because it can make up all these colors…bit dishonest there

Agree completely with @priort and @snibgo, but the question got me to thinking, what would it take to back a sRGB JPEG out to a “larger” profile? I can see a path with tone, as the operations are reversible (ICC TRCs go from source to linear XYZ, etc…), but I think color is not - gamut transformation is a bit of an approximation, and there’s no specific way to determine the original (camera) point on hue line…

So, my surmise is that it’s probably possible to go back to some approximation of scene linear as that is a tone transform, but with color you’re screwed…

Bear-of-little-brain thinking going on here, YMMV.

The Topaz product looks interesting. Thanks for the link.

They ask: Can you tell the difference vs. the original RAW? ( )

Answer: Yes, very easily. The right-hand image has detail around the edge of the mushroom that is absent in the middle image. I assume those are the raw image (converted to sRGB) and the “improved jpeg” respectively.

Some of that detail has been removed in the jpeg image, and some detail is swamped by jpeg artifacts. Fixing the artifacts has also removed some detail.

Expanding a small gamut to a larger gamut, eg sRGB to ProPhotoRGB, is trivial. But doing it accurately is difficult. It assumes we know what process shrunk the gamut, and that it is reversible. I doubt that either assumption is true. For example, the jpeg may have had local adjustment of saturation (like local adjustment of tones), and reversing that accurately is difficult.

I can certainly believe we can start with a horrible jpeg that can’t be edited, and process that image to remove artifacts and invent tones, colours and detail so that we can then edit the image. The result may be pretty, and may be credible.

But will it be as accurate as a process that starts from raw instead of a jpeg? No, because data has been lost.

Out of curiosity I downloaded the 30 day trial. It was late last night I tried it on 3 old jpg file and a new one from my pixel phone…it really didn’t do a very good job…it was late and I just used the auto settings so maybe I will try it one more time…but it wouldn’t be worth the effort in my estimation from what I could get out of it…

Well, there are tonnes of old B&W movies that were converted to color by ‘painting’ the original negatives, so it can be done. Of course the result is just an imaginative representation of the original…

Thanks for the feedback. I understand its not worth it from an image quality perspective. What’s gone is gone. DT does open the jpg, and I’ll live with the result.

I too tried the Topaz labs software, and could not successfully process an image, possibly a lack of memory in my machine.

The simpler thing to think about is that a jpg is (in this case) always a file that has edits done to get back to good proper linear data for scene referree to even have a chance, you would need to undo the edits done to the picture. You can’t without knowing what has been done to it…

… And then not every edit is reversible (far from it), and then you get jpeg compression factors… Etc…

Then again, if you convert the color space from the jpeg from (assumed) sRGB to linear rec2020 and save it as a 16bit tif file, load it in darktable and see what happens.

The quality will not be magically better or course, but the data is in a somewhat linear way.
Good chance there still will be some base curves active in the jpeg data, but you can’t easily undo those without knowing how the jpg was created.

Then again, maybe darktable is smart enough to open the jpg directly and convert the sRGB to its working space directly (linear rec2020) so maybe you can just open the jpg and try how it works?

Converting to different file formats will not gain anything in the end.

You can still use scene-referred tools with JPGs. Unfortunately, since the JPG will have some tone curves applied (e.g. by the camera), the numbers in the image file no longer correspond to the physical reality. Still, you can boost exposure, use the tone equalizer and filmic for tone mapping, like here:

I used filmic without contrast boost, but with a wide latitude:

This is just a quick demo, I’m not saying this is how I’d normally edit this shot. Here is the out-of-camera JPG:

Note that this is using the ‘v3.0 JPEG’ module order; the important part is having exposure and the other tools after input color profile in the pipeline, so it can undo the sRGB encoding (‘gamma’ - which it is not, and AP will kill me for using the g-word if he finds out).

This is what pipeline order looks like:

1 Like

Istvan - thanks so much! Definitely got Exposure working better with this.