1. Welcome to Mu-43.com—a friendly Micro 4/3 camera & photography discussion forum!

    If you are thinking of buying a camera or need help with your photos, you will find our forum members full of advice! Click here to join for free!

Aperture 3 Metadata - Add lenses

Discussion in 'Image Processing' started by CCRoo, Oct 9, 2011.

  1. CCRoo

    CCRoo Mu-43 Regular

    Mar 22, 2011
    Dear Folks,

    I would like to add "legacy lens used" or something like that to the metadata of my photos in Aperture 3. Does anyone have a setup for this they can share?

    (I like the idea of adding photos to the Adapted Lenses Image Gallery on here and this would help me do this better...)

  2. CCRoo

    CCRoo Mu-43 Regular

    Mar 22, 2011
    So I did a little Googling and came up with adding Keywords. Was hoping for something cooler...

    Batch changing keywords in Aperture 3 is a pain. You have to type in the lens until it recognizes something from your keyword list.
  3. Novaron

    Novaron Mu-43 Regular

    Jan 3, 2010
    Falls Church VA
    An oddity is that Aperture will recognize my Pen EP-L3 raw files when I use manual focus lenses but not when I use a mu4-3 lens (Panasonic 20/1.7 and Olympus 45/1.8). Of course Lightroom does not have any such issue. This occurs even if I previously converted files to DNG.
  4. David A

    David A Mu-43 All-Pro

    Sep 30, 2011
    Brisbane, Australia
    Odd. Aperture recognizes my 45mm on my E-P3 and I shoot everything in RAW.

    For the OP, bring up the Keyword HUD (look in the Window menu) and add keywords for all the lenses you want to track. When assigning keywords you can then just pick them from the keyword list in the Inspector. It's simple and quick to add keywords for all your lenses in one go and it's also easy to pick keywords from the list in the Inspector, or at least it is for me.
  5. fin azvandi

    fin azvandi Mu-43 All-Pro

    Mar 12, 2011
    South Bend, IN
    There is a way to do this using Exiftool and an Automator action to directly change the metadata and not rely on Aperture keywords. You have to change the code to reflect the legacy lenses you use (and come up with a way of remembering which lens you used on each shot - if I am using 2 or more legacy lenses at a time I call the longest one "1," then "2," etc and take a picture of my hand with the correct # of fingers each time I switch to a different lens).

    Here is the link to get you started with an overview of what Exiftool and Automator can do.

    And here is the link to a script written by user "Fokalfissur" on the L-Camera Forum that puts it all together in an Automator Service you can run within Aperture.

    Finally, here's how I set up my tweaked and typo-fixed code based on Fokalfissur's post:

    0. Install Exiftool
    1. Start Automator.app
    2. Select "New Service"
    3. Up on top set Service receives "no input" in "Aperture"
    4. From the Actions panel on the side drag "run AppleScript" into the work area.
    5. Delete the AppleScript default code, then paste in the code I've included below.
    6. Tweak the "Lens Description" and "Lens list for the dialog" sections of the code to add the legacy lenses you actually use.
    7. Push the hammer icon to translate/check the code.
    8. Save it (location defaults to ~/Library/Services ) and give it a name, I use "Set Legacy Lens Info"
    9. Start Aperture, the service should now appear in the Services submenu in the Aperture menu.
    10. Test it by making a new Master of a photo by exporting and re-importing, then run this service on the duplicate file to select the lens. You can also select a group of photos to change them all to the same lens at once.
    11. Check the metadata panel, the lens and focal length should be updated!

    NOTE: This Service overwrites the files inside your Aperture library, so make sure it's working properly by testing on duplicate files before turning it loose. It works fine for me but use at your own risk, etc etc. If you'd rather just use it on exported files outside of Aperture I'm sure there's a simpler way to set up the core of this Service as a Folder Action AppleScript.

    on run
        ------------ Get Aperture Libray path from Preference file --------------
        tell application "System Events" to set pLibPath to value of property list item "LibraryPath" of property list file ((path to preferences as Unicode text) & "com.apple.Aperture.plist")
        -- Adjustment if in home directory
        if ((offset of "~" in pLibPath) is not 0) then
            set pHomePath to (do shell script "/bin/echo $HOME")
            set pOffset to offset of "~" in pLibPath
            set pPath to text (pOffset + 1) thru -1 of pLibPath
            set libpath to pHomePath & pPath
            set libpath to pLibPath
        end if
        ------------------- Set some paths and text delimiter --------------------
        -- path to sql
        set sql to "/usr/bin/sqlite3" as Unicode text as string
        -- path to exiftool
        set exiftool to "/usr/bin/exiftool" as Unicode text as string
        -- path to masters folder of managed images
        set managedImagesPath to (libpath & "/Masters/") as Unicode text as string
        -- path to database
        set DBPath to (libpath & "/Database/Library.apdb") as Unicode text as string
        -- store original and change text delimiters for later use in loop
        set savedDelimiters to AppleScript's text item delimiters
        set AppleScript's text item delimiters to {", "}
        ------------------------------ Lens description -------------------------------
        -- this is to set the lens for uncoded glass
        -- as multiple tags are involved each lens will have a list with Lens, focal length and max. aperture
        -- add your uncoded lenses with the same pattern
        -- no need to remove anything here
        -- Leica
        set cron35 to {"Leica Summicron 35mm ASPH", 35, 2} as list
        -- Leica Visoflex
        set elmar65 to {"Leitz Elmar 65mm - Visoflex", "65", "3.5"} as list
        set elmar90 to {"Leitz Elmar 90mm - Visoflex", "90", "4"} as list
        -- Voigtländer
        set voigt15 to {"Voigtländer 15mm", 15, 4.5} as list
        -- Canon
        set canon50 to {"Canon 50mm 1,2", "50", "1.2"} as list
        -- Balgen
        set elmar65b to {"Leitz Elmar 65mm - Balgen", "65", "3.5"} as list
        set milar65b to {"Leitz Milar 65mm - Balgen", "65", "4.5"} as list
        set elmar90b to {"Leitz Elmar 90mm - Balgen", "90", "4"} as list
        -- Konica Hexanon
        set hexanon40 to {"Konica Hexanon 40mm f/1.8", "40", "1.8"} as list
        set hexanon507 to {"Konica Hexanon 50mm f/1.7", "50", "1.7"} as list
        set hexanon55 to {"Konica Macro-Hexanon 55mm f/3.5", "55", "3.5"} as list
        set hexanon57 to {"Konica Hexanon 57mm f/1.4", "57", "1.4"} as list
        set hexanon85 to {"Konica Hexanon 85mm f/1.8", "85", "1.8"} as list
        set hexanon135 to {"Konica Hexanon 135mm f/3.2", "135", "3.2"} as list
        set hexanon200 to {"Konica Hexanon 200mm f/3.5", "200", "3.5"} as list
        set hexanon300 to {"Konica Hexanon 300mm f/4.5", "300", "4.5"} as list
        -------------------------- Lens list for the dialog ----------------------------
        -- you may change the sorting: first lenses are on top of the dialog
        -- if you don't want a lens to appear simply remove the entry 
        set LensList to {hexanon40 as string, hexanon507 as string, hexanon55 as string, hexanon57 as string, hexanon85 as string, hexanon135 as string, hexanon200 as string, hexanon300 as string} as list
        --------------------------------- the dialog -----------------------------------
        -- the choose dialog
        set mychoice to (choose from list LensList with prompt "Choose one." without multiple selections allowed) as Unicode text
        if mychoice is "false" then
            display dialog "error. check lens list dialog"
        end if
        -- the dialog is not possible with list as list elements. So the lenses were displayed as string and converted back to a list here
        set mylens to text items of mychoice as list
        -- this calls the list entries of your chosen lens
        set lensname to first item of mylens
        set lenslengh to second item of mylens
        set lensap to third item of mylens
        ---------------------------------- the loop ------------------------------------
        -- This loop cycles through all the images of your selection in aperture and
        -- looks up where the MASTER of the image is stored and
        -- runs exiftool to make changes on the master
        tell application "Aperture"
            copy selection to theSelection
            repeat with curImgage in theSelection
                set uuid to id of curImgage
                -- get file path from database
                set SQLscript to quote & "select imagePath from RKMaster where UUID=(select masteruuid from RKversion where uuid='" & uuid & "')" & quote
                set bashquery to sql & space & (quoted form of DBPath) & space & SQLscript
                set imagePath to do shell script bashquery
                --setting paths for managed/referenced
                if curImgage is not referenced then
                    set fullImagePath to managedImagesPath & imagePath
                    set fullImagePath to imagePath
                end if
                ---------------------------- the exiftool command --------------------------
                -- this sets lensname + focal lengh + max. aperture + update the approximate aperture
                -- the script will overwrite the original.
                -- You may remove " -overwrite_original_in_place" for testing
                -- keep in mind that exiftool then puts an "_original" at the end of the filename
                -- if you run the script twice, your original is replaced by the altered file in the first run
                -- you may make a finder search for "_original" in Library/Masters to find all the originals (quite a few MB if you batch run the script)           
                do shell script exiftool & " -m -overwrite_original_in_place -Lens='" & lensname & "' -FocalLength=" & lenslengh & " -MaxApertureValue=" & lensap & " -tagsfromfile @ '-xmp-exif:ApertureValue<ApproximateFNumber'" & space & (quoted form of fullImagePath)
                ------------------------------ Refresh metadata ! ---------------------------
                -- this is to see the results in Aperture immediately
                -- not sure if this applies to all versions         
                refresh metadata of curImgage
            end repeat
            ---------------------------------- tidy up a bit --------------------------------
            set AppleScript's text item delimiters to savedDelimiters
        end tell
    end run
    • Like Like x 2
  6. tomrock

    tomrock Mu-43 Regular

    Jun 21, 2010
    Indianapolis, IN
    That Automator script is pretty slick but keep in mind it's writing to your original raw files. If you don't have them backed up separately somewhere, you may have an issue in the future. Then again, you may not.

    I use keywords and it works just fine. Still doesn't show the aperture, but at least I know which lens I used.
  7. Ray Sachs

    Ray Sachs Super Moderator Subscribing Member

    Apr 17, 2010
    Near Philadephila
    I find it more odd that it WILL recognize EPL3 files with ANY lens since Apple doesn't support the EPL3 or EPM1 yet. It SHOULD recognize EP3 files because they've already added support for that camera. But why it would recognize and support EPL3 files with legacy lenses is beyond me.

    I use a program from the App Store called ExifChanger to change my EPL3 files to EP3 files and then I can import them into Aperture. Its an extra step until Apple gets around to updating their raw support again. Exifchanger is basically just a friendlier front end to ExifTool (and it includes ExifTool with it), so it makes it easier to make changes to individual files or batches of them since you don't have to know the ExifTool commands to make it work. I don't remember if it was free or cost $5 or something, but it wasn't much and if it did cost a few bucks, it was well worth it. I'm sure you could use it to add your lens information as well.

  8. David A

    David A Mu-43 All-Pro

    Sep 30, 2011
    Brisbane, Australia
    I wasn't suggesting that it should recognize and support any lens but the post I relied to said it wasn't recognizing some native lenses and I was saying that it was recognizing at least one of the lenses he mentioned in my case.

    As for the Pl3 and PM1, I wasn't aware that they weren't recognized. I expected that they would be since they use the same processing and sensor as the P3 so I assumed thar their RAW files would also be handled since the P3's files are now handled by Aperture. I obviously made a mistake there.
  9. redcapestudio

    redcapestudio Mu-43 Rookie

    Sep 1, 2011
    Los Angeles
    Thank you for posting this code. I have just started with Aperture and was looking for a way to add metadata to uncoded lenses. In addition to the lens name, focal length, and max aperture, I have been able to add focal length (35mm) as a fourth item. I have tried to add the aperture value as a fifth item but it does not show up in Aperture.

    In the original code on the L Camera forum it appears that the aperture value is being pulled from the Leica Makers notes as ApproximateFNumber. I've been able to delete this code and have the script run correctly but it won't set the aperture value.

    Here are the lines I changed or added.

    set pentaxA50 to {"SMC Pentax-A 50mm f/1.7", "50", "100", "1.7", "1.7"} as list

    set lensap to fifth item of my lens

    do shell script exiftool & " -overwrite_original_in_place -Lens='" & lensname & "' -FocalLength=" & lenslength & " -FocalLengthIn35mmFormat=" & lenslength35 & " -MaxApertureValue=" & lensmaxap & " -ApertureValue=" & lensap & " " & (quoted form of fullImagePath)

    Any thoughts on getting an aperture value to show up in Aperture would be greatly appreciated.
  10. fin azvandi

    fin azvandi Mu-43 All-Pro

    Mar 12, 2011
    South Bend, IN
    For the "Aperture" field, the problem is that for native lenses that field (in exiftool you would write to -FNumber ) is meant for the actual aperture setting used in the photo, not the lens' maximum aperture. I had some mixed success with using a second script that presented a list of potential aperture values and then applied the selected value to individual photos, but eventually gave up because it's just too much hassle to remember.

    As for the 35mm-equivalent focal length, my native m4/3 lenses don't fill that field so I didn't look into it. I'm using an E-PL1, have the later bodies have been updated to write to that field? Maybe I'll add that command too!
  11. redcapestudio

    redcapestudio Mu-43 Rookie

    Sep 1, 2011
    Los Angeles
    The -FNumber tag is exactly what I was looking for. It works. I have some photo projects in Aperture that I shot with the Pentax lens wide open so I'm going to enter the actual aperture setting for those. The 35mm-equivalent focal length does show up for my native lenses using a GH2 body.

    Thanks for the help.
    • Like Like x 1
  12. thearne3

    thearne3 Mu-43 Top Veteran

    Jan 28, 2010
    Redding, CT USA
    I'm getting a syntax error at the line 'refresh metadata of curImgage': Expected end of line, etc. but found identifier Any ideas?
  13. MrDoug

    MrDoug Mu-43 Top Veteran

    Sep 5, 2011
    Boise, Idaho
    oops. sorry
  14. WT21

    WT21 Super Moderator Subscribing Member

    Feb 19, 2010
    I didn't notice this post before.

    I did a similar post for LR over in the post processing forum.

    I think (for Aperture) if you just apply the metadata changes to the file BEFORE Aperture import, it will be OK. LR is a little easier, because LR doesn't seal up the files all tight and tidy. They're left in the basic file system, so you can easily edit them AFTER import, but if you do it before the Ap import, you'll likely be OK. With LR you can "read metadata from file" -- so if you change the metadata after import, the LR database can be dynamically updated. Does Aperture support something similar????

    See https://www.mu-43.com/f97/adding-legacy-lens-meta-data-using-exiftools-lightroom-mac-17728/ for the lightroom workflow, if that is at all helpful.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.