Project

General

Profile

How can you read BlueBalance, GreenBalance and RedBalance with exiv2?

Added by Andreas S. over 3 years ago

Hi,

I'm trying to write a python script with the gexiv2 python3 bindings to create white balance presets. However I cound't find a way using the exiv2 command line tool or via python to read the BlueBalance, GreenBalance and RedBalance from the exiv metadata. It is possible using exiftool.

Does someone know how to do it?

Thanks.


Replies (14)

RE: How can you read BlueBalance, GreenBalance and RedBalance with exiv2? - Added by Robin Mills over 3 years ago

Can you attach a test image and I'll investigate and let you know.

I recently helped somebody to build py3exiv2 on Centos. Building py3exiv2 on MacOS or Windows is challenging (not impossible, however not easy). http://dev.exiv2.org/projects/exiv2/wiki/BuildingPy3Exiv2onCentos

I discussed something recently with somebody and red/green/blue was part of the discussion. I can't remember what was discussed and your test image will probably restore my memory.

RE: How can you read BlueBalance, GreenBalance and RedBalance with exiv2? - Added by Andreas S. over 3 years ago

Here is the file: https://xor.cryptomilk.org/dt/7M3_DAYLIGHT.ARW

I'm looking for the following values:

$ exiftool -s -t -WhiteBalance -WhiteBalanceFineTune -ColorTemperature -RedBalance -BlueBalance 7M3_DAYLIGHT.ARW
WhiteBalance    Daylight
WhiteBalanceFineTune    0
ColorTemperature        Auto
RedBalance      2.296875
BlueBalance     1.617188

I wasn't able to get the any of the *Balance tags using exiv2 on the command line either.

RE: How can you read BlueBalance, GreenBalance and RedBalance with exiv2? - Added by Robin Mills over 3 years ago

I don't have good news for you. Here's what I see:

609 rmills@rmillsmbp:~/Downloads $ exiv2 -pa --grep white/i 7M3_DAYLIGHT.ARW 
Exif.Image.WhitePoint                        Rational    2  313/1000 329/1000
Exif.SubImage1.WhiteLevel                    Short       1  16383
Exif.Sony2.WhiteBalanceFineTune              Long        1  0
Exif.Sony2.WhiteBalance                      Long        1  Daylight
Exif.Sony2.WhiteBalance2                     Short       1  Daylight
Exif.Photo.WhiteBalance                      Short       1  Manual
610 rmills@rmillsmbp:~/Downloads $ 
There was something reported some time ago about this and didn't make much progress at that time: http://dev.exiv2.org/issues/949

I've looked at the exiftool Sony Tag documentation and can't see anything about RedBalance or BlueBalance. https://sno.phy.queensu.ca/~phil/exiftool/TagNames/Sony.html

I've look at the exiftool Minolta Tag documentation and it's documented: https://sno.phy.queensu.ca/~phil/exiftool/TagNames/Minolta.html However, I'm not convinced that the Minolta documentation is relevant for your image.

I don't know how exiftool has discovered this:

627 rmills@rmillsmbp:~/Downloads $ exiftool 7M3_DAYLIGHT.ARW  | grep -i blue
Blue Balance                    : 1.617188
CFA Pattern                     : [Red,Green][Green,Blue]
628 rmills@rmillsmbp:~/Downloads $ exiftool -verbose 7M3_DAYLIGHT.ARW  | grep -i blue
629 rmills@rmillsmbp:~/Downloads $ 
I have remembered where red/blue stuff was recently discussed. I'm involved in an Open Source Community Effort to reverse engineer Canon's new CR3 format. So although r/g/b was in that conversation, it does not relate to your ARW file.

Regrettably I don't believe Exiv2 can be of further help to you at this time. Here's the current discussion document about v0.28. As you can see, the top priority matter for 2019 is "Improved raw image code and test" http://dev.exiv2.org/news/3

Remarkably, I had a discussion with a user earlier today about IIQ files (another raw format) for which our support is limited. That discussion lead to a similar conclusion. Please understand that Team Exiv2 is a small group of volunteers. The manufacturers are paid for equipment which take images with undocumented metadata. It's a pity that manufacturers don't contribute to Exiv2.

RE: How can you read BlueBalance, GreenBalance and RedBalance with exiv2? - Added by Andreas S. over 3 years ago

So first, this is not only related to Sony, the same applies to Nikon! So I'm not sure if this is a vendor specific tag at all :-)

Example:

exiftool -s -t -WhiteBalance -WhiteBalanceFineTune -ColorTemperature -RedBalance -BlueBalance 2017-09-20_Peru_0202.nef
WhiteBalance    Auto1
WhiteBalanceFineTune    1 0
RedBalance      2.179688
BlueBalance     1.726563

exiv2 -pa 2017-09-20_Peru_0202.nef | grep BalanceExif.Nikon3.WhiteBalance                     Ascii      13  AUTO1       
Exif.Nikon3.WhiteBalanceBias                 SShort      2  1 0
Binary file (standard input) matches

I wanted to write a wb_extract.py for darktable to automatically generate C code from a bunch of RAW files for WhiteBalance presets. As there are python bindings for exiv2 I thought I would go with that but it looks like I have to postpone that :-)

RE: How can you read BlueBalance, GreenBalance and RedBalance with exiv2? - Added by Robin Mills over 3 years ago

Thanks for your feedback. May I ask if you are cross with me? I have tried to answer your question.

The key Exif.Nikon3.WhiteBalanceBias indicates that in the Nikon3 MakerNote, there is a tag called "WhiteBalanceBias". In an .ARW (a sony format, I understand), you will find keys such as "Exif.Sony2.WhiteBalance" which indicates that the tag is in the Sony2 MakerNote. So different manufacturers store this information in different ways in their images.

The RedBalance/BlueBalance/GreenBalance Tags in Exiv2 are all in the manufacturer's makernotes:

638 rmills@rmillsmbp:~/gnu/github/exiv2/exiv2/src $ grep -i -e RedBalance -e BlueBalance -e GreenBalance *.cpp 
olympusmn_int.cpp:        TagInfo(0x1017, "RedBalance", N_("Red Balance"),
olympusmn_int.cpp:        TagInfo(0x1018, "BlueBalance", N_("Blue Balance"),
panasonicmn_int.cpp:        TagInfo(0x0011, "RedBalance", N_("Red Balance"), N_("Red balance (found in Digilux 2 RAW images)"), panaRawId, panaRaw, unsignedShort, -1, printValue),
panasonicmn_int.cpp:        TagInfo(0x0012, "BlueBalance", N_("Blue Balance"), N_("Blue balance"), panaRawId, panaRaw, unsignedShort, -1, printValue),
pentaxmn_int.cpp:        TagInfo(0x001b, "BlueBalance", N_("Blue balance"),
pentaxmn_int.cpp:        TagInfo(0x001c, "RedBalance", N_("Red balance"),
639 rmills@rmillsmbp:~/gnu/github/exiv2/exiv2/src $ 
WhitePoint and WhiteBalance are in the Exif standard (and there's other white metadata buried in the metadata):
644 rmills@rmillsmbp:~/gnu/github/exiv2/exiv2/src $ exiv2 -pa --grep White/i ~/Downloads/7M3_DAYLIGHT.ARW 
Exif.Image.WhitePoint                        Rational    2  313/1000 329/1000
Exif.SubImage1.WhiteLevel                    Short       1  16383
Exif.Sony2.WhiteBalanceFineTune              Long        1  0
Exif.Sony2.WhiteBalance                      Long        1  Daylight
Exif.Sony2.WhiteBalance2                     Short       1  Daylight
Exif.Photo.WhiteBalance                      Short       1  Manual
645 rmills@rmillsmbp:~/gnu/github/exiv2/exiv2/src $ 
The py3exiv2 binding for Exiv2 exposes more or less the same information as the Exiv2 command-line program as pythonic structures such as an array.

RE: How can you read BlueBalance, GreenBalance and RedBalance with exiv2? - Added by Andreas S. over 3 years ago

Ok, I see. I will wait till there is support for those values in exiv2 and then write the python script. Thanks for your help!

RE: How can you read BlueBalance, GreenBalance and RedBalance with exiv2? - Added by Robin Mills over 3 years ago

Andreas:

I don't want you to believe that I've agreed to research Blue/Red/GreenBalance and add support for those ARW keys to Exiv2. The team is small and we have many requests. This will be an unknown amount of work and feels less important that other projects being considered for v0.28.

I don't understand the relationship between darktable and python. If you're generating C code using python, you can use something like popen3() in python to run exiftool and don't need me to do anything. I hope everything works out well for you.

Robin

RE: How can you read BlueBalance, GreenBalance and RedBalance with exiv2? - Added by Andreas S. over 3 years ago

I can use exiftool and there are scripts available using it to generate the values already. I just wanted to do it with exiv2. However it isn't possible right now. It isn't really a problem.

I'm working on open source projects too. I know what it means to not find time to work on some things, so don't worry :-)

Cheers,

Andreas

RE: How can you read BlueBalance, GreenBalance and RedBalance with exiv2? - Added by Robin Mills over 3 years ago

I've no doubt you understand this. In fact, one of the best aspects of open-source is the support. I'm certain that the support provided by Exiv2 (and many other projects) is better than you'll get from major software vendors in Silicon Valley.

One reason that open-source support is good is because you're usually speaking directly to the Engineer who does the code. No middle-men, office-politicians, or marketing folk. If I can do it easily, I'll add features to Exiv2 immediately. No delay. No messing. In the case of this red/blue/green balance issue, it's not easy and will have to be stacked for the future. When will it get done? No idea!

Oh, if you really want this done, can you add an "Issue" on GitHub to be sure it's tracked and not forgotten. Discussions on the Redmine Forum aren't tracked. Be sure to reference this Redmine discussion in the GitHub Issue. https://github.com/Exiv2/exiv2/issues

RE: How can you read BlueBalance, GreenBalance and RedBalance with exiv2? - Added by Phil Harvey over 3 years ago

For ARW files (and many other file types), the ExifTool Red/BlueBalance tags are Composite tags derived from the values of the following tags:

WB_RGGBLevels
WB_RGBGLevels
WB_RBGGLevels
WB_GRBGLevels
WB_GRGBLevels
WB_GBRGLevels
WB_RGBLevels
WB_GRBLevels
WB_RBLevels
WBBlueLevel
WBGreenLevel

You should be able to extract the appropriate tags from the list above using Exiv2 and calculate the balances yourself.

RE: How can you read BlueBalance, GreenBalance and RedBalance with exiv2? - Added by Robin Mills over 3 years ago

Thank you, Phil for this insight. Looking forward to meeting you one day in England, Canada, or somewhere.

RE: How can you read BlueBalance, GreenBalance and RedBalance with exiv2? - Added by Andreas S. over 3 years ago

Thanks for the info Phil, but Exiv2 doesn't know about Levels either.

exiv2 -pa _7M30999.ARW | grep -i level
Exif.SubImage1.WhiteLevel Short 1 16383
Exif.Sony2.FlashLevel SShort 1 Normal

RE: How can you read BlueBalance, GreenBalance and RedBalance with exiv2? - Added by Phil Harvey over 3 years ago

Sorry, I assumed that Exiv2 was more up-to-date than that. Here is what ExifTool extracts for this file:

% exiftool ~/Desktop/7M3_DAYLIGHT.ARW '-*level*' -G1
[SubIFD] White Level : 16383
[Sony] Flash Level : Normal
[Sony] Battery Level : 38%
[Sony] WB RGB Levels : 587 256 412
[SR2SubIFD] Black Level : 512 512 512 512
[SR2SubIFD] WB RGGB Levels Auto : 2364 1024 1024 1640
[SR2SubIFD] WB RGGB Levels : 2352 1024 1024 1656
[SR2SubIFD] WB RGB Levels Daylight : 2352 1024 1656
[SR2SubIFD] WB RGB Levels Cloudy : 2536 1024 1520
[SR2SubIFD] WB RGB Levels Tungsten : 1460 1024 2916
[SR2SubIFD] WB RGB Levels Flash : 2576 1024 1468
[SR2SubIFD] WB RGB Levels 4500K : 2124 1024 1856
[SR2SubIFD] WB RGB Levels Shade : 2788 1024 1372
[SR2SubIFD] WB RGB Levels Fluorescent : 2176 1024 2420
[SR2SubIFD] WB RGB Levels Fluorescent P1 : 2256 1024 1772
[SR2SubIFD] WB RGB Levels Fluorescent P2 : 2496 1024 1632
[SR2SubIFD] WB RGB Levels Fluorescent M1 : 1700 1024 2900
[SR2SubIFD] WB RGB Levels 8500K : 2928 1024 1300
[SR2SubIFD] WB RGB Levels 6000K : 2516 1024 1536
[SR2SubIFD] WB RGB Levels 3200K : 1632 1024 2544
[SR2SubIFD] WB RGB Levels 2500K : 1272 1024 3484
[SR2SubIFD] White Level : 15360 15360 15360

RE: How can you read BlueBalance, GreenBalance and RedBalance with exiv2? - Added by Robin Mills over 3 years ago

Gentlemen

I am hosting a meeting of Team Exiv2 in my home in England in two weeks time. Here's the discussion paper for the meeting: http://dev.exiv2.org/news/3

Your concerns about Balance and Levels will be discussed. I can't promise that we will give this high priority as we have many other projects which also seek attention.

You have to understand that over the last 6 years, I have been supporting and developing Exiv2 mostly on my own. I'm very pleased to have another couple of Engineers working with me over the last 9 months and perhaps more can be achieved as we move into the future.

Robin

    (1-14/14)