Keep color correction when converting

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
dustinw
Posts: 13
Joined: 2017-01-17T10:44:07-07:00
Authentication code: 1151

Keep color correction when converting

Post by dustinw »

Hello, I've read and done some searching to try and find a solution, but was unable to. If I somehow missed the correct discussion, please point me in the right direction. :)

We're using ImageMagick to do image conversion, etc. on our DAM, which is ResourceSpace (http://www.resourcespace.com/). Everything is mostly working well, but we have ran into an issue - one that I'm hoping can be solved with ImageMagick.

We have a large library of images. We often color correct these photos with Adobe's Camera Raw, usually in Adobe Bridge or Lightroom. Since DNG uses a single file to hold any changes made instead of using sidecar files (.XMP) like .NEF, .CR2 do, we've began converting all our raw photos to DNG. When we upload these DNG files to ResourceSpace if it uses the embedded JPEG Preview, the color correction is kept and the image is shown properly. However, when ResourceSpace generates other JPEG image sizes for download, it uses the embedded preview file to create these. The embedded preview appears to be a 72 dpi, smaller version. Which means that you can't download a full resolution JPEG. I've made sure that we've selected the Full Size JPEG Preview when converting to DNG. This seems to just keep the dimensions, but at 72 dpi. I believe this is the problem, and I don't know that this can be fixed.

However, if we were to not use the embedded JPEG Preview, and let ImageMagick handle creating the preview, it is able to generate the preview at full size and all the other smaller versions we need. This all works well, and is the preferred solution. The problem with this method is that the color correction applied to the DNG seems to be lost and isn't used to create the JPEGs - meaning they don't look as we intended.

Is there a way for ImageMagick to keep those color corrections applied and saved in the DNG when creating JPEGs?

Sorry for the long-winded post! I just wanted to be as thorough as possible.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Keep color correction when converting

Post by snibgo »

dustinw wrote:We often color correct these photos with Adobe's Camera Raw, usually in Adobe Bridge or Lightroom. ... the color correction applied to the DNG seems to be lost...
Perhaps your color correction doesn't change pixels, but merely records metadata that says what the correction should be. IM wil ignore that metadata.

Perhaps ACR has an option to actually change the pixels, rather than merely recording metadata.
snibgo's IM pages: im.snibgo.com
dustinw
Posts: 13
Joined: 2017-01-17T10:44:07-07:00
Authentication code: 1151

Re: Keep color correction when converting

Post by dustinw »

Thanks for the reply. The corrections we're doing are just metadata as you mentioned, which we prefer, since it is non-destructive. Is there any way for IM to read and use that information when generating JPGs?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Keep color correction when converting

Post by snibgo »

It would occur while reading DNG, not writing JPG. But, no, IM doesn't read that metadata.
snibgo's IM pages: im.snibgo.com
dustinw
Posts: 13
Joined: 2017-01-17T10:44:07-07:00
Authentication code: 1151

Re: Keep color correction when converting

Post by dustinw »

Thanks for the information. Looks like we'll have to find another solution. We were trying to avoid having multiple copies of files on the DAM. Hoping to have the JPGs created from the DNG files.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Keep color correction when converting

Post by snibgo »

If you can extract that metadata, perhaps with exiftool, it might be possible to translate it into IM terms.
snibgo's IM pages: im.snibgo.com
wiseman
Posts: 14
Joined: 2019-10-02T09:26:26-07:00
Authentication code: 1152

Re: Keep color correction when converting

Post by wiseman »

snibgo wrote: 2017-01-17T13:55:27-07:00 If you can extract that metadata, perhaps with exiftool, it might be possible to translate it into IM terms.
Could you please give me more info about how to do it? I mean, what parameters I need to extract and supply in order to generate jpgs with color corrections included from dng files. Also need a sample IM command with such parameters.

I could extract metadata data prior to running the imagemagick(IM) command to generate eps file or jpg files.

But I would like to have the dng's color corrections taken into effect while IM generates eps or jpg files.

thank you
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Keep color correction when converting

Post by snibgo »

wiseman wrote:I mean, what parameters I need to extract and supply in order to generate jpgs with color corrections included from dng files. Also need a sample IM command with such parameters.
What "color corrections included from dng files"?

Two year ago, I wrote "Perhaps your color correction doesn't change pixels, but merely records metadata that says what the correction should be." Note the "perhaps". Perhaps there isn't such metadata.

Perhaps you can link to a DNG file that does contain colour-correction metadata.
snibgo's IM pages: im.snibgo.com
wiseman
Posts: 14
Joined: 2019-10-02T09:26:26-07:00
Authentication code: 1152

Re: Keep color correction when converting

Post by wiseman »

snibgo wrote: 2019-10-02T09:58:40-07:00
wiseman wrote:I mean, what parameters I need to extract and supply in order to generate jpgs with color corrections included from dng files. Also need a sample IM command with such parameters.
What "color corrections included from dng files"?

Two year ago, I wrote "Perhaps your color correction doesn't change pixels, but merely records metadata that says what the correction should be." Note the "perhaps". Perhaps there isn't such metadata.

Perhaps you can link to a DNG file that does contain colour-correction metadata.
Color corrections are mainly w.r.t tint, exposure, highlights, shadows, whites, blacks, contrast, clarity, vibrance details

I will get a sample dng file link for this issue.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Keep color correction when converting

Post by snibgo »

"Tint, exposure, highlights" etc are settings made within the camera, as hints to software either within the camera when making JPEGs or external software, eg readers of raw files. Each manufacturer has their own definition of these fields, and they don't publish the definitions.
snibgo's IM pages: im.snibgo.com
wiseman
Posts: 14
Joined: 2019-10-02T09:26:26-07:00
Authentication code: 1152

Re: Keep color correction when converting

Post by wiseman »

snibgo wrote: 2019-10-03T02:00:14-07:00 "Tint, exposure, highlights" etc are settings made within the camera, as hints to software either within the camera when making JPEGs or external software, eg readers of raw files. Each manufacturer has their own definition of these fields, and they don't publish the definitions.
Hi,

Basically, following are a set of sample DNG files:

original DNG file (fileA):
https://anonymousfiles.io/MhaMm2Nx/

Color corrected DNG file (fileB):
https://anonymousfiles.io/Od2vB0P6/

Basically, I would like to invoke imagemagick on each of the dng file listed above and get a similar looking jpg file.


For example, fileA's imagemagick jpg output should look exactly with same color and brightness of fileA's dng file.

Similarly, fileB's imagemagick jpg output should look exactly with same color and brightness of fileB's dng file.

I could see tons of info stored in Xmp and other data.

Please let me know whether it is possible to get it done via imagemagick.

thanks
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Keep color correction when converting

Post by snibgo »

Your links give "Error 522 Connection timed out".
snibgo's IM pages: im.snibgo.com
wiseman
Posts: 14
Joined: 2019-10-02T09:26:26-07:00
Authentication code: 1152

Re: Keep color correction when converting

Post by wiseman »

snibgo wrote: 2019-10-04T02:45:12-07:00 Your links give "Error 522 Connection timed out".
My apologies.

Please use the below links and let me know if any issues faced:

https://www.amazon.com/clouddrive/share ... 6Kwod0jZIg

https://www.amazon.com/clouddrive/share ... kYpQR7A5Ik

Thanks
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Keep color correction when converting

Post by snibgo »

The two files each contain one Color Filter Array, and a full-size JPEG. The "color corrected" version has almost the same CFA image, but the JPEG is clearly edited. Exiftool shows editing has been done by Adobe tools.

The point of a DNG file is to make a vendor-independent version of the CFA image, so I'm not surprised the Adobe software hasn't changed this. I expect you could tell it to make a debayered image if you want, and that would give the best result.

If you want JPG versions of the (edited) DNG files, I suggest extracting them:

Code: Select all

exiftool -b -JpgFromRaw original_DSC180307_0853.DNG >o.jpg

exiftool -b -JpgFromRaw color_corrected_DSC180307_0853.DNG >c.jpg
o.jpg is 8256x5504 pixels. c.jpg is slightly smaller, 7778x5185 pixels.

The raw images in both files are Color Filter Array. IM delegates reading CFA. I prefer to use dcraw directly, eg:

Code: Select all

%DCRAW% -6 -w -T -O o.tiff original_DSC180307_0853.DNG

%DCRAW% -6 -w -T -O c.tiff color_corrected_DSC180307_0853.DNG
The tiffs are slightly larger than the JPGs: both are 8288x5520. These tiffs are almost identical.

We can tweak the colours in o.tiff to look like c.jpg, for example by matching histograms:

Code: Select all

call %PICTBAT%matchHisto o.tiff c.jpg oc.tiff
The result is quite good, but not as good as c.jpg.
snibgo's IM pages: im.snibgo.com
wiseman
Posts: 14
Joined: 2019-10-02T09:26:26-07:00
Authentication code: 1152

Re: Keep color correction when converting

Post by wiseman »

snibgo wrote: 2019-10-04T11:46:12-07:00

If you want JPG versions of the (edited) DNG files, I suggest extracting them:

Code: Select all

exiftool -b -JpgFromRaw original_DSC180307_0853.DNG >o.jpg

exiftool -b -JpgFromRaw color_corrected_DSC180307_0853.DNG >c.jpg

Thanks for the detailed reply.

I have been using the embedded jpgs by extracting them (i had imagemagick delegates.xml settings to extract jpg and use in case of dng). But often times, the embedded image used to be smaller version (768x1024) for some unknown reason of the adobe software resulting in tons of images unable to produce larger eps files etc since the source file is of lower resolution.

That is the reason I'm looking for an option to not use the embedded jpg file rather than use the dng file itself with color corrections to generate high resolution eps file etc.

I will go through the options you had suggested and getback on this.

Thanks a lot
Post Reply