Jump to content

Aperture 3.0.1 Metadata Information


richfx

Recommended Posts

  • Replies 57
  • Created
  • Last Reply

You know Michael,

not being an applescript expert, I didn't find a proper way to include the terminal command in a script that AP3 can execute just after importing, as Fokalfissur and myself hoped.

 

So for the moment, Adobe DNG Converter seems to me the best solution!

Does Adobe DNG C. fill missing exif tags for the M9 also?

Link to post
Share on other sites

(...)So for the moment, Adobe DNG Converter seems to me the best solution!

Does Adobe DNG C. fill missing exif tags for the M9 also?

 

Yes, it does; not sure about any other changes applied to the pic...

 

Best,

Michael

Link to post
Share on other sites

Made a droplet in Automator:

 

1. get Unix path of files (options: quotes unchecked)

2. execute shell script (options: shell =bin/bash, as argument)

cat
exiftool $1 -overwrite_original_in_place -tagsfromfile @ '-xmp-aux:Lens<LensType' -tagsfromfile @ '-xmp-exif:ApertureValue<ApproximateFNumber'

now save it as an app. The "$1" is the path from the previous action. You need a third party action for the getting the path - you can get it here. It is easy to get the path in Apple Script, too (posixpath). This should be a good starting point for whatever.

 

The forum should have a download area for the non-geeks.

Link to post
Share on other sites

You know Michael,

not being an applescript expert, I didn't find a proper way to include the terminal command in a script that AP3 can execute just after importing, as Fokalfissur and myself hoped.

 

Try not to import from aperture. Make workflow 1. type: plug in for digital images 2. run shell script 3. import to aperture.

Will try it on the weekend.

 

However, the conversion of the existing libray for uncoded lenses is another thing.

Link to post
Share on other sites

Over Eastern I found time to play with exiftool. This is the first part for setting the lensname, its focal length and max aperture. More to come.

Feedback, code review and critic are welcome. I tried to comment it in detail. Just copy all the code to a new AppleScript and read the comments (they start with "--").

 

-- this script is to set the Name of the Lens, its focal length and its max. aperture in the exif
-- Open with AppleScript Editor (ships with each Mac) and save as Application. This App serves as a droplet: just drag your dngs on it.
-- exiftool must be installed. http://www.sno.phy.queensu.ca/~phil/exiftool/
-- The script just works for one Name set manually. However, it can provide a list and you just have to alter one name.
-- You may add other lenses to that list and share with others. Alternatively you may send me (Fokalfissur) your lens and I'll do it for you 

-- on open is necessary for droplets
on open these
-- loop for each file
repeat with this in these
	-- don't know why, but this is necessary:
	tell application "Finder"
		-- check if file is a dng:
		if name of this does not end with ".dng" then
			-- file is no dng
			display dialog "Duh! There was a least one file that isn't  a .dng."
		end if

		-- First get unix path for proper use in shell:
		set qpath to quoted form of POSIX path of this

		try
			-- this is to set the lens for uncoded glass
			-- you may add your uncoded lenses with the same pattern, changing just the variable name in "set thelens to xxx"  in the script afterwards
			-- as multiple tags are involved each lens will have a list with Lens, focal length and max Aperture
			-- list values {"Lensname", "Focallenght, "max. Aperture"}
			set cron35 to {"Leica Summicron 35mm ASPH", 35, 2} as list
			set voigt15 to {"Voigtländer 15mm", 15, 4.5} as list
			set canon50 to {"Canon 50mm 1,2", "50", "1.2"} as list
			set elmar65 to {"Leitz Elmar 65mm - Visoflex", "65", "3.5"} as list
			set elmar90 to {"Leitz Elmar 90mm - Visoflex", "90", "4"} as list
			set elmar65b to {"Leitz Elmar 65mm - Balgen", "65", "3.5"} as list
			set milar65b to {"Leitz Milar 65mm - Balgen", "65", "4.5"} as list

			-- link to your lens entry above here (instead the "cron35"):
			set mylens to cron35 as list
			-- a dialog to confirm your choice (just the lensname is displayed)
			display dialog item 1 of mylens

			-- 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

			-- now the beef
			do shell script "/usr/bin/exiftool -Lens='" & lensname & "' -FocalLength=" & lenslengh & " -MaxApertureValue=" & lensap & " " & qpath
		on error
			-- something went wrong with this try block of the script:
			display dialog "Lens: Oh shi-"
		end try

	end tell
end repeat
end open

Link to post
Share on other sites

This script simply uses Alex' code with an AppleScript as droplet.

 

-- on open is necessary for droplets
on open these
-- loop for each file
repeat with this in these
	-- don't know why, but this is necessary:
	tell application "Finder"
		-- check if file is a dng:
		if name of this does not end with ".dng" then
			-- file is no dng
			display dialog "Duh! There was a least one file that isn't  a .dng."
		end if

		-- First get unix path for proper use in shell:
		set qpath to quoted form of POSIX path of this

		-- now for the beef…
		-- note that the original is saved with .original. However, this only once. A second try will overwrite the .original with the first altered version.
		-- So work on copies. If you feel safe you may add the option "-overwrite_original" to the shell scripts.			
		try
			do shell script "/usr/bin/exiftool " & qpath & " -tagsfromfile @ '-xmp-aux:Lens<LensType'"
			-- where:
			-- "/usr/bin/exiftool" = full path. Just "exiftool" may cause some problems in shell scripts via Apple script
			-- "-tagsfromfile @ '-xmp-aux:Lens<LensType'" = "-tagsfromfile" copies tags. 
			-- left to the "<" is the destination group, right the origin. The LensType info is copied to the group xmp-aux into the field Lens

		on error
			-- something went wrong with the shell script:
			display dialog "Oh shi-"
		end try

	end tell
end repeat
end open

-- to get this script work as droplet: open in AppleScript editor and save as Application

Link to post
Share on other sites

Just batch run the first script on my pics (set lens data). There is a bug: The choosen lens is prompted each cycle. So better delete the "display dialog item 1 of mylens" or just put "--" in front of it.

 

I just run both scripts on app. 1000 pics and this is slow. As each manipulation reads and writes the file there is no reason not to do a script with export within Aperture. I always wanted to avoid that export-import but you run into a thousand problems if you don't do.

 

So the next script will be from aperture, with sandy's better g-stop, too.

Link to post
Share on other sites

  • 3 weeks later...
Great job, and I'm waiting your Aperture script but I understand that your job it's a great advance in the right direction.

 

If you are wondering what's with my script: I didn't have the time to do much (shitstorms…) and I ran into several problems:

- It seems not possible to do it just with AS (even Aperture 3 is quite limited in AS)

- only way is with sqlite and poke into the Library database

- I found this for Aperture 2: Database Access

- database structure has changed :(

- if I get this script running in A3 it would be wonderful: works with both managed/referenced files

 

However. I am a complete noob regarding sql stuff and the weather is getting better from day to day…

 

If you want to play a little bit the the database: There is a wonderful program out there (all platforms): sqlite database browser. Point it to …/Aperturelibrary/Aperture.aplib/Library.apdb

 

Sven

Link to post
Share on other sites

Thanks for all the information so far.

 

I'd like to contribute a very small script.

How to use it:

 

1. Change the path to the exiftool to the location where your exiftool is actually located. (Line 17).

2. Move the Skript to a convenient location, I use ~/bin since it is included in my PATH variable. "chmod +x" it, to make it executable. I guess you can do this in Finder, too. My skript is called "m9exit2xmp.sh".

3. Open Terminal, cd to the Location of your Aperture Library

4. "m9exif2xmp.sh <aperturelibrary>"

 

The Skript now looks for every L*.DNG file in <aperturelibrary> and modifies those files as worked out in this thread.

 

Note 1: Use at your own risk!

Note 1b: Especially because it overwrites original files!

Note 2: You need the latest exiftool version.

 

You can even try this on the images that are still on the SD cards.

 

#! /bin/bash

# Skript for Leica Files, to include gAperture and Lense Name
# in an "Aperture readable" way into the original DNG 

# @param path Path, within a recursive search will be performed

[ "$1" == "" ] && {
echo "No path specified."
exit 1
}
[ ! -e $1 ] && {
echo "Path does not exist."
exit 1
}
PFAD=$1
EXIFTOOL=/path/to/exiftool

find $PFAD -name "L*.DNG" | while read URI
do
echo "-> $URI"
$EXIFTOOL -overwrite_original_in_place -tagsfromfile @ '-xmp-aux:Lens<LensType' -tagsfromfile @ '-xmp-exif:ApertureValue<ApproximateFNumber' $URI
done

Link to post
Share on other sites

Seems like it works with managed and referenced imaged out of Aperture. As the exiftool stuff seems trivial now (thank to Alex) I haven't included any working code. Its just about getting the image path.

 

If you want to ask anything - do it.

 

(*
Script
-determines up your current Library
-gets the path of the master image of your selection (should work on both managed and referenced)
-runs exiftool

How to use:
Select one or more images in Aperture and then run script
*)

on run
-----------------------------------------------------------
-- Get Aperture Libray path from Preference file and set some paths (sql, exiftool)
-----------------------------------------------------------
tell application "System Events" to set p_libPath 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 p_libPath) is not 0) then
	set p_homePath to (do shell script "/bin/echo $HOME")
	set p_offset to offset of "~" in p_libPath
	set p_path to text (p_offset + 1) thru -1 of p_libPath
	set libpath to p_homePath & p_path
	log libpath
else
	set libpath to p_libPath
end if
-- path to sql
set sql to "/usr/bin/sqlite3" as string
-- path to exiftool

-- Set Path to sqlight database in aperture library
set DBPath to (libpath & "/Database/Library.apdb") as string
tell application "Aperture"
	-----------------------------------------------------------
	-- Now loop for every image in the Aperture selection
	-----------------------------------------------------------
	copy selection to theSel
	repeat with curImg in theSel
		--set theName to name of curImg
		set uuid to id of curImg
		-- get file path from database
		set SQLimagePath to quote & "select imagePath from RKMaster where UUID=(select masteruuid from RKversion where uuid='" & uuid & "')" & quote
		set SQLscript to sql & space & (quoted form of DBPath) & space & SQLimagePath
		-- first try always gets error 10004, even with tell system events ???
		set imagePath to do shell script SQLscript
		--setting paths for managed/referenced in home directory/referenced
		if curImg is not referenced then
			set fullImagePath to libpath & "/" & imagePath & "/"
		else
			set fullImagePath to imagePath
		end if
		-----------------------------------------------------------
		-- Now do shit
		-----------------------------------------------------------

		-- example: (Note: lensname, lenslengh and lensap not defined in this script		
		-- do shell script "/usr/bin/exiftool -Lens='" & lensname & "' -FocalLength=" & lenslengh & " -MaxApertureValue=" & lensap & " " & fullImagePath

		----------------------------------------------------------------------------------
		------------------------------ Refresh metadata ! ---------------------------
		----------------------------------------------------------------------------------			
		refresh metadata of curImg

	end repeat
end tell
end run

Link to post
Share on other sites

  • 9 months later...
Problem 1) solved:

exiftool -overwrite_original_in_place -tagsfromfile @ '-xmp-aux:Lens<LensType' -tagsfromfile @ '-xmp-exif:ApertureValue<ApproximateFNumber'

:D

 

P.S.: Alex, you might want to include a -P to preserve the date and time of the original file when overwriting in place.

Link to post
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...