Bad white balance in some Nikon D70 NEF files


Certain NEF files from a Nikon D70 have a strong green cast in the white balance.  The embedded thumbnail shows the expected white balance, but not the main image.  I suspect this is because libraw is misinterpreting the white balance metadata.  The "cam_mul" values are coming out as 1.0, 1.0, 1.0 which seems unlikely.  I can send you the NEF file but I'm not sure how to attach it here.

Dear Sir:

It looks like this shot has its metadata modified using UniWB. In this case it will look green. The shot to the left will be displayed properly. You can upload the file to some file hosting service (Google Drive, Dropbox, WeTransfer are some of the free ones) and email the link to 

Ok, I sent the image via Google Drive to  Thank you!

Dear Sir:

Thank you for making the file available.

Turned out, it was either a Nikon's bug or the file was modified manually.

We worked around this by ignoring inconsistent white balance data: FRV 1.5.3-1502 here:  (please select version for your platform)

I tested my NEF files with FRV 1.5.3-1502 beta and they all appear correctly now.
I noticed that the files that showed up wrong all had a "Software" field in the metadata of "Nikon Transfer 6.2.7 W".  The ones that were showing up correctly had a Software field of "Ver .2.00".  I would guess that the "Nikon Transfer" software probably introduced the problem, and files transfered directly off the camera are fine.
Was this fix added to libraw?  We use libraw in our software.

You can do this:
in parseNikonMakernote find processing of tag == 0xbf3c6c20 and edit it like this:

if (WhiteBalanceAdj_active) {
+#if 1
+ union {
+ double dbl;
+ unsigned long long lng;
+ } un;
+ un.dbl = getreal(12);
+ if ((un.lng != 0x3FF0000000000000ULL) &&
+ (un.lng != 0x000000000000F03FULL)) {
+ cam_mul[0] = un.dbl;
+ cam_mul[2] = getreal(12);
+ cam_mul[1] = cam_mul[3] = 1.0;
+ i -= 16;
+ } else i -= 8;
cam_mul[0] = getreal(12);
cam_mul[2] = getreal(12);
cam_mul[1] = cam_mul[3] = 1.0;
i -= 16;

Add new comment