Change dng metadata of manual lens only in a directory

Started by msandersen, February 15, 2015, 10:32:23 AM

Previous topic - Next topic

msandersen

Hi
I just got a manual fisheye lens, an opteka 6.5mm fisheye (same as Samyang 8mm apparently)
I'd like Aperture on my Mac to recognise it correctly once imported. My workflow:
1. Import files from camera card into a folder via Image Capture
2. Convert to DNG via Adobe DNG Converter (it apparently tags it as a 50mm lens), and copy CR2 files to a Temp directory as a precaution until DNGs successfully imported.
3, I rename the files with a Renamer app for aesthetics from IMG_xxxx to Imagexxxx
4. Here I'd like to run a script to add metadata to the DNG files from the Fisheye lens only, i.e. using an -if statement
5. Import into Aperture.

I tried using a program called Exif Editor, which uses Exiftool, but it currently has no filtering of conditional statements, and also does;t support all the necessary tags. Samples I imported into Aperture still appeared as an Unknown lens and 50mm lens.

Researching the use of Exiftool and the necessary tags and their format is the first tricky part, the 2nd is to try and make a script out of it, either a Bash script or Applescript. Whether it is executed from the terminal or from double-clicking is not important.

So far I've arrived at this line: (note I decided for these tests to put the original manufacturer's value of 8mm, not the Opteka brand's claimed 6.5mm)
exiftool -if 'not $ApertureValue' -ApertureValue="8.0" -Lens="8.0 mm" -LensInfo="8.0 8.0 3.5 22" -FocalLength="8.0" -MaxApertureValue="22.00" -LensModel="6.5mm f/3.5 Manual Focus Aspherical Circular Fisheye" -LensMake="Opteka" -focallengthin35mmformat="13" /Users/Shared/_Photos/test

where the 'test' directory has 9 files; 4 images in cr2 and dng from a Tamron lens, 3 from a Sigma lens in dng and tiff, and two from the Manual fisheye in dng and cr2.
Originally I had trouble because I wrote it out in a text editor, which converted quotes from straight to curly.

The result from the above produced this result in the terminal:
192-168-1-3:test Thor$ exiftool -if 'not $ApertureValue' -ApertureValue="8.0" -Lens="8.0 mm" -LensInfo="8.0 8.0 3.5 22" -FocalLength="8.0" -MaxApertureValue="22.00" -LensModel="6.5mm f/3.5 Manual Focus Aspherical Circular Fisheye" -LensMake="Opteka" -focallengthin35mmformat="13" /Users/Shared/_Photos/test
    1 directories scanned
    8 files failed condition
    1 image files updated


The updated file was the correct Fisheye dng file, the cr2 version of the same failed the condition.

Running this command to test
exiftool -s -ApertureValue -Lens -LensInfo -FocalLength -MaxApertureValue -LensModel -LensMake -focallengthin35mmformat /Users/Shared/_Photos/test
produces this (truncated to sample files)

======== /Users/Shared/_Photos/test/Image7923 [2015-02-09]-Sigma.dng
ApertureValue                   : 8.0
Lens                            : 8.0 - 16.0 mm
LensInfo                        : 8-16mm f/?
FocalLength                     : 10.0 mm
MaxApertureValue                : 4.8
LensModel                       : 8-16mm
======== /Users/Shared/_Photos/test/IMG_9168-Tamron.dng
ApertureValue                   : 8.0
Lens                            : 17.0 - 50.0 mm
LensInfo                        : 17-50mm f/?
FocalLength                     : 40.0 mm
MaxApertureValue                : 2.8
LensModel                       : 17-50mm

======== /Users/Shared/_Photos/test/IMG_9220-fisheye.CR2
ApertureValue                   : inf
Lens                            : 0.0 mm
LensInfo                        : ?mm f/?
FocalLength                     : 50.0 mm
LensModel                       :
======== /Users/Shared/_Photos/test/IMG_9220-fisheye.dng
ApertureValue                   : 8.0
Lens                            : 0.0 mm
LensInfo                        : 8mm f/3.5-22
FocalLength                     : 8.0 mm
MaxApertureValue                : 22.0
LensModel                       : 6.5mm f/3.5 Manual Focus Aspherical Circular Fisheye
LensMake                        : Opteka
FocalLengthIn35mmFormat         : 13 mm


The cr2 file shows an Aperture value of "inf", I don't know what that means, but would be the reason it failed the condition.

Importing the test image into Aperture, it shows up correctly as "6.5mm f/3.5 Manual Focus Aspherical Circular Fisheye" with the fields "8mm" and "f/8" and 35mm Focal length of 13mm. Confusing mixing the 6.5 and 8mm I know, the model name is what it is, I'd rather have the 'correct' focal length in the metadata (not that I have any way of testing either way), going by Photozone and other sources.

Maybe someone could critique this, if there are other tags I ought to include while at it, some I shouldn't bother with, and if testing on ApertureValue is the best way (it was somewhat arbitrary, but it was one of the missing values I wanted to set which exist in the other lenses).

Secondly, how could this be written into either a Bash script or Applescript? I expect the former is the easiest.
Additionally, I would like to add the Renaming portion into either the Exiftool output, or the Bash script (IMG_xxxx > Imagexxxx)

Any help appreciated.

Thanks

msandersen

One further mystery. I tried running the command on an entire directory, and only the fisheye photos were changed as expected, running exiftool over them showed the correct metadata (except for Lens, which shows 0.0mm). However, on importing them, Aperture info shows the wrong info, i.e. a 50mm Unknown lens of unknown aperture. Yet the referenced files have the correct info. So, is this something to do with exif versus XMP data or something?
Running
exiftool -s -xmp:ApertureValue -xmp:Lens -xmp:LensInfo -xmp:FocalLength -xmp:MaxApertureValue  -xmp:LensModel  -xmp:LensMake -xmp:focallengthin35mmformat /Volumes/Photos\ RAID/2015/02-15\ Art\ Gallery\ of\ NSW/Image9234\ \[2015-02-15\].dng produces only
Lens :8.0mm
whereas running
exiftool -s -exif:ApertureValue -exif:Lens -exif:LensInfo -exif:FocalLength -exif:MaxApertureValue  -exif:LensModel  -exif:LensMake -exif:focallengthin35mmformat /Volumes/Photos\ RAID/2015/02-15\ Art\ Gallery\ of\ NSW/Image9234\ \[2015-02-15\].dng
produces
ApertureValue                   : 8.0
LensInfo                        : 8mm f/3.5-22
FocalLength                     : 8.0 mm
MaxApertureValue                : 22.0
LensModel                       : 6.5mm f/3.5 Manual Focus Aspherical Circular Fisheye
LensMake                        : Opteka
FocalLengthIn35mmFormat         : 13 mm

which tells me that Aperture seems to read the XMP values. But strangely my first single-file import test worked, and Aperture has an Exif Info view which shows the incorrect values of 50mm Unknown lens etc. Very confusing.

Phil Harvey

The 'inf' means infinity, and you can add this to your condition if you want: -if 'not $aperturevalue or $aperturevalue eq "inf"'

I can't say whether this is the best way to recognize these files, but anything that works is fine.

Quote192-168-1-3:test Thor$ exiftool -if 'not $ApertureValue' -ApertureValue="8.0" -Lens="8.0 mm" -LensInfo="8.0 8.0 3.5 22" -FocalLength="8.0" -MaxApertureValue="22.00" -LensModel="6.5mm f/3.5 Manual Focus Aspherical Circular Fisheye" -LensMake="Opteka" -focallengthin35mmformat="13" /Users/Shared/_Photos/test

The renaming may be done using ExifTool, but it will require a second command (if you want to rename all the files, not just the ones passing the -if condition).  In a bash script, the command could look like this:

exiftool -filename=Image%-4f.%e $*

Then the bash script is run like this: scriptname /Users/Shared/_Photos/test

I can't help much with figuring out what tags Apple Aperture recognizes.

- 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 ($).

msandersen

Thanks Phil, I need to do some more experimentation this morning. I know from other places that various image editors, and in this case Adobe and Apple, handle metadata differently where there is an overlap of Exif and XMP; Adobe, having defined XMP, has a clear preference for it, while Apple puts higher precedence on Exif data. Annoying when you edit something in one app, and it does't show up in another; e.g. Photoshop adds to the XMP, whereas another program will read the Exif.
That is my understanding from a while back; Aperture uses the OS to parse Raw files, so this is subject to change with system updates. This will be more prominent in the upcoming Photos app.

Hence I tested what tags were Exif and what were XMP; I read up on your specs for Exif, so I expected -Lens to be an Exif tag, but it only shows as XMP:Lens.

I just did a quick test of the original DNG converted by Adobe DNG Converter from CR2, using the two exiftool commands above testing for Exif and XMP tags respectively, and I'm a little puzzled about the Lens tag:
192-168-1-3:test Thor$ exiftool -s  -ApertureValue -Lens -LensInfo -FocalLength -MaxApertureValue -LensModel -LensMake -focallengthin35mmformat /Users/Shared/_Photos/test/IMG_9220-fisheye.dng
Lens                            : 0.0 mm
FocalLength                     : 50.0 mm
LensModel                       :
192-168-1-3:test Thor$ exiftool -s  -exif:ApertureValue -exif:Lens -exif:LensInfo -exif:FocalLength -exif:MaxApertureValue -exif:LensModel -exif:LensMake -exif:focallengthin35mmformat /Users/Shared/_Photos/test/IMG_9220-fisheye.dng
FocalLength                     : 50.0 mm
192-168-1-3:test Thor$ exiftool -s  -xmp:ApertureValue -xmp:Lens -xmp:LensInfo -xmp:FocalLength -xmp:MaxApertureValue -xmp:LensModel -xmp:LensMake -xmp:focallengthin35mmformat /Users/Shared/_Photos/test/IMG_9220-fisheye.dng
192-168-1-3:test Thor$

As you can see, using no Group before the tags, it shows it has Lens: 0.0mm, FocalLength: 50.0mm, and a blank but set LensModel. In the Exif group, you just have FocalLength:50.0mm, and in XMP, you have nothing. Where is Lens?
Checking the corresponding original CR2, it has no XMP values, but returns this for exif:
ApertureValue                   : inf
LensInfo                        : ?mm f/?
FocalLength                     : 50.0 mm
LensModel                       :

From my previous test above, when you set -lens="8.0mm", it turns up in xmp:Lens and not in Exif like the others. But -Lens returns "0.0mm" from somewhere, which I'd like to set to "8.0mm". Maybe Aperture, like Adobe DNG Converter, assumes 50mm FocalLength if it can't determine one. Otherwise, is there another group I should be checking and resetting? And if so, shouldn't -Lens="8.0mm" set all of them?

Update: Adobe Camera Raw, XMP, and Aperture
I opened one of the tagged and imported DNGs from above in Adobe Raw/Photoshop, and it shows the correct aperture, f-stop and focal length. Interestingly, since Adobe automatically updates DNGs on exit, that one file then showed up correct metadata in Aperture (all of it), while the others still show no updated metadata. So I tested the Exif and XMP tags above again on it and one of the others in the same batch not showing up correctly in Aperture. Interesting. Exif tags are the same, but in the one opened in Camera Raw, it now reads the additional XMP tags:
==== "/Volumes/Photos RAID/2015/02-15 Art Gallery of NSW/Image9230 [2015-02-15].dng" ====
Lens                            : 6.5mm f/3.5 Manual Focus Aspherical Circular Fisheye
LensInfo                        : 8mm f/3.5-22

while the other file not touched by Camera Raw reads
==== "/Volumes/Photos RAID/2015/02-15 Art Gallery of NSW/Image9231 [2015-02-15].dng" ====
Lens                            : 8.0 mm

in other words, Adobe Camera Raw took the value from exif:LensModel and put it into XMP:Lens, overwriting the 8mm I had put.
I then ran
exiftool -xmp:Lens="6.5mm f/3.5 Manual Focus Aspherical Circular Fisheye" -xmp:-LensInfo="8.0 8.0 3.5 22"
on a few of the imported dng files, and Aperture promptly updated to show the correct metadata! Even the ones only in the Exiftags, like focallengthin35mmformat.

So, by adding the above XMP-specific tags to the command, it should work.

As for the Bash script, I will need to study some more, I will have to copy and paste some script and replace the guts with the Exiftool command, it is a bit beyond me atm. Until then, I have a command for fixing up the images.
I've installed pyexiftoolgui, and might try using that for a while.

Phil Harvey

Quote from: msandersen on February 15, 2015, 09:00:44 PM
In the Exif group, you just have FocalLength:50.0mm, and in XMP, you have nothing. Where is Lens?

All your questions should be answered by the same solution as FAQ 3.  Extract your tags without specifying the group name, and add -a -G to the command.

QuoteSo, by adding the above XMP-specific tags to the command, it should work.

Great!

- 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 ($).