Set FNumber and FocalLength with ExifTool

Started by Hans Kraus, May 15, 2025, 09:20:41 AM

Previous topic - Next topic

Hans Kraus

Hi,
I finally used, after expanding all tags I found, exiftool -fnumber=1.8 -aperturevalue=1.8 -targetaperture=1.8 -maxaperture=1.8 -minaperture=32 -focaltype=Fixed -focallength=135 -MakerNotes:FocalLength=135 -Canon:FocalLength=135 -Exif:FocalLength=135 -MaxFocalLength=135 -MinFocalLength=135 -Canon:MaxFocalLength=135 -Canon:MinFocalLength=135 -MaxFocalLength2=135 -MinFocalLength2=135 -overwrite_original_in_place -Progress -P <filename>.CR3
to set FNumber and FocalLength. I still got a problem, not all occurrences of these values are set, some retain at 0. I get: [MakerNotes]    FocalLength                     : 135
[MakerNotes]    MinFocalLength2                 : 135
[MakerNotes]    MaxFocalLength2                 : 135
:
[MakerNotes]    FocalLength                     : 0
[MakerNotes]    FNumber                         : 0
:
[MakerNotes]    MaxFocalLength                  : 0
[MakerNotes]    MinFocalLength                  : 0
:
[MakerNotes]    FNumber                         : 1.78179743628068
[MakerNotes]    FNumber                         : 0.0220970869120796
[EXIF]          FNumber                         : 1.8
:
[XMP]           FNumber                         : 1.8
[XMP]           FocalLength                     : 135
That is to set meaningful values for a fully manual lens on a Canon R7.
Any help appreciated, Hans

StarGeek

Can you share a file where this happens?
"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

greybeard

If you look at the output using G1 instead of G0 you will see why you missed some of the tags, something like

exiftool -a -G1 -s xx.cr3

there is more than one category of makernotes in these files

StarGeek

I'm more inclined to think it's an error in the file, which is why I asked for a sample.

This alone should update all existing FocalLength tags
-focallength=135

Looking through the Canon tags, I can't find FocalLength that isn't writable. So I can't think of any reason offhand that the tags wouldn't be updated.
"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

greybeard

Quote from: StarGeek on May 15, 2025, 01:34:05 PMI'm more inclined to think it's an error in the file, which is why I asked for a sample.

This alone should update all existing FocalLength tags
-focallength=135

Looking through the Canon tags, I can't find FocalLength that isn't writable. So I can't think of any reason offhand that the tags wouldn't be updated.

Its because they are MakerNotes but not Canon - some of those tags will show as Track4 in a CR3 file - thats why I suggested using G1 rather than G0 to view the tags

StarGeek

Ah, yeah. I can see that when checking the couple of CR3 files I have. If they are in Track# group, then exiftool won't be able to edit those as they are part of the stream (see QuickTime Stream Tags).
"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

Hans Kraus

Thanks for the help. The not-set values are indeed in [Track4]. A sample file is to be found in Example File Dir. How do I set these values too?
Kind regards, Hans

StarGeek

It's probably not possible. But there probably isn't a program other than exiftool that can even see those tags. Programs are almost certainly going to read the EXIF tags.
"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

Hans Kraus

Well, 'IMatch' (photools.com) works. But 'Capture One' only displays the aperture but not the focal length. Of course my first thought was that the missing values are responsible for that. I will now ask the people at 'Capture One' why the focal length is missing.
Kind regards, Hans

StarGeek

Quote from: Hans Kraus on May 16, 2025, 11:20:07 AMWell, 'IMatch' (photools.com) works.

If you mean works in that it reads the Track4 data, then yes, that's because it uses exiftool behind the scenes. But I don't see how it could write it unless it's somehow using FFmpeg to do so. Which would be a really bad idea IMO, as FFmpeg is quite limited in what metadata it can write.
"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

Hans Kraus

Hi, the problem seems to be that exiftool writes the changes into the cr3 file. After I do:
exiftool -overwrite_original -P -progress -m -ext cr3 -tagsfromfile @ -srcfile %d%f.xmp .
exiftool -overwrite_original -P -progress -m -ext cr3 -XMP:all= .
even 'Capture One' works. Is there a possibility to persuade exiftool to do that all with one command? I tried '-xmp' but that delivered a warning.
Kind regards, Hans

Phil Harvey

Hi Hans,

Your first command writes only the XMP file.  The CR3 won't be touched.

The second command will delete all XMP from the CR3 file.

Since these commands are processing two different files, they must be two separate commands.  But you may combine these two commands into a single command line like this:

exiftool -tagsfromfile @ -srcfile %d%f.xmp -execute -XMP:all= -common_args -overwrite_original -P -progress -m -ext cr3 .

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Hans Kraus

Hi Phil, thanks for the help and explanation. I'm sorry, I stated the thing(s) I'd like to do not clearly.
I took pics with a fully manual lens and I tried to append Aperture and Focal Length of that lens to the Exif data. I succeded with1.) exiftool -fnumber=1.8 -aperturevalue=1.8 -targetaperture=1.8 -maxaperture=1.8 -minaperture=32 -focaltype=Fixed -focallength=135 -MaxFocalLength=135 -MinFocalLength=135 -MaxFocalLength2=135 -MinFocalLength2=135 -overwrite_original_in_place -progress -P *.CR3The problem is that 'Capture One' displays only the aperture but not the focal length. After trying2.) exiftool -overwrite_original -P -progress -m -ext cr3 -tagsfromfile @ -srcfile %d%f.xmp .
3.) exiftool -overwrite_original -P -progress -m -ext cr3 -XMP:all= .
'Capture One' displays the correct focal length too. It seems to me that line 1.) writes the data only to the Exif- and XMP-part in the CR3 file and leaves the XMP sidecar file untouched. 'Capture One' takes the focal length from the XMP sidecar file and ignores the info in the CR3 file. Line 3.) is necessary because another tool prefers data from the XMP part of the CR3 file if it exists.
Is it possible to persuade 'exiftool' to write only Exif-data in the CR3 file and XMP data in the XMP sidecar file?
Best regards, Hans

Phil Harvey

Hi Hans,

To write only EXIF and MakerNotes tags in the CR3 with command 1:

exiftool -exif:fnumber=1.8 -makernotes:fnumber=1.8 -exif:aperturevalue=1.8 -makernotes:targetaperture=1.8 -makernotes:maxaperture=1.8 -makernotes:minaperture=32 -makernotes:focaltype=Fixed -exif:focallength=135 -makernotes:focallength=135 -makernotes:MaxFocalLength=135 -makernotes:MinFocalLength=135 -makernotes:MaxFocalLength2=135 -makernotes:MinFocalLength2=135 -overwrite_original_in_place -progress -P *.CR3

Then you can run command 2 to copy the metadata to the XMP file.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).