Question

I have some cr2 files.

I would like to make a C++ program, or write a script, that separates the different cr2 files with different focal lengths, and puts them in separate directories.

How can I do that ?

I have access to the Canon EDSDK and LibRaw but i am not sure where i can find the focal length information.

I also have a little utility "ExifTool" that can read the metadata - but i don't know how to get it to do something i want - and the gui version seems to crash when reading 5000 files over the network...

Please can somebody give me a suggestion ?

Was it helpful?

Solution

The EXIF specification can be found here:

http://www.exif.org/specifications.html

You will need to read the EXIF data, and find the entry which contains a "tag" of 37386 or 0x920A. This is followed by a "RATIONAL" number, which is essentially two unsigned integers forming a fraction, for example 400/20 = 20 mm, as is 80/5 or 20/1. A 14.5mm lens would have to be (at least) stored as 29/2, but could be stored as 145/10 or 1450/100 - or a large number of other variants.

Of course, if you use for example ExifTool, you can easily do this with a script, or use it's Perl binding to write a script in Perl.

There is also a C++ interface to use with exiftool: http://owl.phy.queensu.ca/~phil/cpp_exiftool/

Using the TagInfo that you get back from ImageInfo(), it should be possible to find the FocalLength and move the files accordingly.

I'm not going to write the code for you, but the above information should be able to give you an idea.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top