Page 1 of 2

JPG Created from RAW File is dark

Posted: 2017-02-06T09:09:54-07:00
by dustinw
I'm trying to resolve an issue for our DAM (ResourceSpace) that is using ImageMagick to create JPGs from our RAW files. Everything is working great, except the JPGs created appear darker than they should be.

Here is a sample image:

This was saved from Photoshop from the RAW file. No adjustments have been made.
Image

Here is the same file after ImageMagick has created the JPG preview
Image

Can someone point me in the right direction of why this may be? Thanks!

Re: JPG Created from RAW File is dark

Posted: 2017-02-06T09:36:21-07:00
by magick
You can upgrade your ImageMagick release or edit ResourceSpace and add -colorspace sRGB to the 'convert' utility command line.

Re: JPG Created from RAW File is dark

Posted: 2017-02-06T09:52:15-07:00
by dustinw
Thanks for the response! We checked the log, and here is the command that was performed:

+matte -quality 90 +matte -strip -colorspace sRGB

It looks like the sRGB parameter is already set. Is there anything else that we could be missing?

EDIT: I forgot to mention that we just updated ImageMagick a couple of days ago. We're now running the 7.0.4 version.

Re: JPG Created from RAW File is dark

Posted: 2017-02-06T12:05:56-07:00
by fmw42
Your PS created file uses ADOBE RGB profile. What profile are your getting or setting in your IM created image?

In IM 7, matte is deprecated. You should be using -alpha off. I do not know why you have +matte twice in the command line?

Why did you add -strip to your command and why -colorspace sRGB. The -strip may be removing meta data that PS is using. If your raw images were already RGB, then you would not need to add -colorspace sRGB. But you might need to add ADOBE RGB profile to your IM created image.

Is photoshop reading some meta data from the camera to tell it how to adjust the brightness contrast?

You might want to post a link to your RAW image and your exact command line for reading and processing it in IM. Also what processing you did in PS. That way some one here might be able to process your RAW image in IM and see what is happening and compare it to your PS processed image.

Re: JPG Created from RAW File is dark

Posted: 2017-02-06T12:16:43-07:00
by fmw42
Perhaps PS is doing some auto-contrast stretch to make the image full dynamic range. You could add -auto-level to your IM command line.

Re: JPG Created from RAW File is dark

Posted: 2017-02-06T12:25:05-07:00
by snibgo
As Fred says.

In addition, why are the images small, 1024x682? Did you resize them to that? In Photoshop, did you convert the full image or merely copy the preview? (The preview in a raw camera file is a processed small version of the full image. IM can't see the preview, but exiftool can.)

Re: JPG Created from RAW File is dark

Posted: 2017-02-06T12:50:23-07:00
by dustinw
Thank you for the help. Those command line parameters are what ResourceSpace (The digital asset management) software we're using generated. I was unsure why matte was listed twice as well. As far as the -strip parameter, I probably should have not mentioned that one, since the way this software works, is it generates a large JPG, then the smaller sizes are created from the larger version. The -strip command is only used on the smaller files that are generated. I'm assuming they do that for performance? Maybe?

There isn't any metadata adjusting the image, and I've included a link to the RAW file, so if anyone else wouldn't mind giving this a shot to see if they get the same results. (if there is better place to put the file for download, please let me know)

(the download link will show above the preview at the top of the page)
https://1drv.ms/i/s!Avsp9SaMaXIJrplZaySky-8bMsQAFg

I've tried running from the command line on my Windows 10 machine to bypass ResourceSpace, just in case there was anything else I may be missing. I'm getting the same results (darker jpg). I've tried using no colorspace parameter, adding sRGB or RGB. All produce darker JPGs as well. I also tried downloading the Adobe RGB profile like you mentioned. I tried that as well, but I was still getting the darker JPG. Here's the syntax I used, just in case:

Code: Select all

magick _INT5470.NEF -profile "AdobeRGB1998.icc" test.jpg

Re: JPG Created from RAW File is dark

Posted: 2017-02-06T13:23:16-07:00
by fmw42
Can you tell me what arguments you put in the RAW panel to import the NEF file. I tried using what IM suggested for the file size, etc, but my ancient Photoshop CS would not open the file. I think it wants the size of the header.

My test of converting the NEF in IM 7.0.4.7 Q16 Mac OSX came out dark also. Also adding -auto-level. Also converting to TIF.

So I think Photoshop may be reading some color correction information and automatically applying it.

Re: JPG Created from RAW File is dark

Posted: 2017-02-06T13:26:44-07:00
by Bonzo
There always seems to be a problem with NEF files and it has come up before.

I had similar problems years ago with canon RAW files and I edited something in the deligates file, but from memory IM is using a different RAW processor now?

Re: JPG Created from RAW File is dark

Posted: 2017-02-06T13:40:25-07:00
by fmw42
It is likely the dng delegate.xml line. The file shows DNG meta data. Here is the dng line, which calls ufraw. So likely ufraw needs some modification to handle the auto-contrast/brightness in some way. I do not use ufraw. But you might try processing your NEF using ufraw directly and see what arguments need changing in the DNG line of the delegates.xml file.


<delegate decode="dng:decode" command="&quot;ufraw-batch&quot; --silent --create-id=also --out-type=png --out-depth=16 &quot;--output=%u.png&quot; &quot;%i&quot;"/>

Perhaps one of the IM users who process raw files might be able to suggest the proper ufraw command.

Re: JPG Created from RAW File is dark

Posted: 2017-02-06T13:46:20-07:00
by dustinw
fmw42 wrote: 2017-02-06T13:23:16-07:00 Can you tell me what arguments you put in the RAW panel to import the NEF file. I tried using what IM suggested for the file size, etc, but my ancient Photoshop CS would not open the file. I think it wants the size of the header.

My test of converting the NEF in IM 7.0.4.7 Q16 Mac OSX came out dark also. Also adding -auto-level. Also converting to TIF.

So I think Photoshop may be reading some color correction information and automatically applying it.
If you're asking about the Camera RAW panel that pops up, I'm not making any adjustments there. Other than that, I'm not sure. I'm a long-time Photoshop user, but I don't remember anything about the header size. :)

What's strange about it too, is even when it was uploaded to onedrive, the preview that it generated had the proper brightness/color. So, if it is something that's embedded, Onedrive was able to read it too. Windows Explorer's preview reads it properly as well (in Windows 10, at least).

Re: JPG Created from RAW File is dark

Posted: 2017-02-06T13:59:41-07:00
by snibgo
You haven't answered my questions above, starting with "In addition, why are the images small, 1024x682?"

I think Windows Explorer etc use the preview image, rather than de-Bayering the raw image.

Re: JPG Created from RAW File is dark

Posted: 2017-02-06T14:07:36-07:00
by dustinw
fmw42 wrote: 2017-02-06T13:40:25-07:00 It is likely the dng delegate.xml line. The file shows DNG meta data. Here is the dng line, which calls ufraw. So likely ufraw needs some modification to handle the auto-contrast/brightness in some way. I do not use ufraw. But you might try processing your NEF using ufraw directly and see what arguments need changing in the DNG line of the delegates.xml file.


<delegate decode="dng:decode" command="&quot;ufraw-batch&quot; --silent --create-id=also --out-type=png --out-depth=16 &quot;--output=%u.png&quot; &quot;%i&quot;"/>

Perhaps one of the IM users who process raw files might be able to suggest the proper ufraw command.
Ok. I think you're onto something here. I'm learning as I go here. I downloaded and ran UFRaw. I open the same NEF file, and it shows that it's dark, just like the JPGs I've been getting from IM. After following this gentleman's instructions:
http://blog.crushedredpepper.com/nikon/raw.html

I used the color profile he linked, and now it looks like it should.

So, I go back to IM on the command line and try to generate a JPG using that same color profile. The brightness level seems correct, but the color is VERY vivid and kind of crazy looking... I'll report back if I figure it out.

Re: JPG Created from RAW File is dark

Posted: 2017-02-06T14:11:36-07:00
by dustinw
snibgo wrote: 2017-02-06T13:59:41-07:00 You haven't answered my questions above, starting with "In addition, why are the images small, 1024x682?"

I think Windows Explorer etc use the preview image, rather than de-Bayering the raw image.
I apologize. I somehow missed that post. I did resize the images so they wouldn't be so large. You may be correct that Windows Explorer (and even Onedrive) use an embedded preview. I had forgotten about that.

Re: JPG Created from RAW File is dark

Posted: 2017-02-06T15:06:54-07:00
by snibgo
exiftool says the NEF file contain three images:

PreviewImage 570x375 (JPEG)
JpgFromRaw 4288x2848 (JPEG)
raw image 4320x2868 (12-bit Bayer)

So, if you get an image from Photoshop or whatever, the size will give you a clue about which image has been used.

You can get the JPEGs from:

Code: Select all

exiftool -PreviewImage -b _INT5470.NEF >p.jpg
exiftool -JpgFromRaw -b _INT5470.NEF >j.jpg
Those JPEGs are rather more saturated than the Photoshop result.

I don't use ufraw. I do use dcraw, for example to convert the raw image:

Code: Select all

dcraw -6 -w -T -O x3.tiff _INT5470.NEF
This uses dcraw's "automatically brighten", and uses the camera white balance. The result is very close to the Photoshop result. (This output is sRGB, but dcraw can give AdobeRGB if you prefer.)