read, manipulate and write CFAPattern2 in one line?

Started by reisschuessel, August 26, 2017, 07:10:49 PM

Previous topic - Next topic

reisschuessel

Hi,

as i am currently experimenting with channel swapping red and blue by manipulating the CFAPattern2 tag i was wondering if it is possible to change the value of this tag in one line by exiftool?

Example:
get the value of this tag -> "2 1 1 0" -> change it to "0 1 1 2" -> write it back

My goal is a Lightroom Plugin for win and mac that detects the current CFAPattern2 and then changes it automatically in way that red and blue get swapped.

Thanks,
Niels

Niels

500px: 500px.com/oejeblikket

Hayo Baan

Hi Niels,

You can write the tag easily: exiftool -CFAPattern2="0 1 1 2" FILE You will probably need to explicitly state the group in which the tag exists though since otherwise exiftool might write the changes to the default position which is probably wrong. To do so use exiftool -SubIFD1:CFAPattern2="0 1 1 2" FILE (change SubIFD1 for the group the tag is in, you can view the tag groups by adding e.g. -G1 to the command listing the tag; exiftool -G1 -CFAPattern2 FILE)

However, I doubt that this will accomplish what you're after; I changed the pattern in one of my raw files and opened it in Camera Raw, everything was the same as without the change...
Hayo Baan – Photography
Web: www.hayobaan.nl

StarGeek

If it's a simple reverse of the string and no double digits, you could try something like this:
exiftool "-CFAPattern2<${CFAPattern2;$_=reverse}"
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

reisschuessel

Quote from: StarGeek on August 27, 2017, 03:29:27 PM
If it's a simple reverse of the string and no double digits, you could try something like this:
exiftool "-CFAPattern2<${CFAPattern2;$_=reverse}"
Thanks a lot StarGeek!
I think this will do the trick for me.  :)

The majority of cfapatterns i've seen so far are either 0 1 1 2 or 2 1 1 0. One exception is from a Panasonic GF5 wich is 1 2 0 1 - but this is also reversible with correct result.

Quote from: Hayo Baan on August 27, 2017, 04:53:36 AM
I changed the pattern in one of my raw files and opened it in Camera Raw, everything was the same as without the change...
Hi Hayo,

i have to admit that the files behave a bit strange in Lightroom at first after changing the cfapattern2.
After Changing you have to do "Update DNG Preview & Metadata" and even after that it takes some time until Lightroom catches up.
Also i only used DNGs - either converted from RAWs or out of cam.
Maybe give it a try by using DNGs?


Niels

500px: 500px.com/oejeblikket

Hayo Baan

Quote from: reisschuessel on August 28, 2017, 12:31:08 PM
Hi Hayo,

i have to admit that the files behave a bit strange in Lightroom at first after changing the cfapattern2.
After Changing you have to do "Update DNG Preview & Metadata" and even after that it takes some time until Lightroom catches up.
Also i only used DNGs - either converted from RAWs or out of cam.
Maybe give it a try by using DNGs?

Interesting, with DNGs it indeed works, leading to different colours. Fun! DNGs also don't have the problem that exiftool writes the CFAPattern2 to the "wrong" location if you don't specify the exact location. Saves some arguments :)
Hayo Baan – Photography
Web: www.hayobaan.nl