iPhoto et tags EXIF
Adapté d’un script par Andrew Turner, ce script Applescript permet d’ajouter des tags Exif (commentaires, titre, date, etc.) à vos photos à partir des méta-données que vous aurez saisies dans iPhoto. Pour ce faire, sélectionnez vos photos dans iPhoto (pas des albums mais bien des photos) et exécutez ce script. Voir plus bas pour quelques commentaires et le script à télécharger.
– images using the information current in iPhoto.
–
– Author: Andrew Turner (http://highearthorbit.com)
– Editor: BaroqueW (http://www.baroquew.net)
–
property copyright : ""
property URL : ""
property exifToolOriginal : "_original"
– True retains copyright, False means Public Domain
property Copyrighted : "False"
tell application "iPhoto"
activate
try
copy (my selected_images()) to these_images
if these_images is false or (the count of these_images) is 0 then ¬
error "Please select a single image."
set counter to 0
repeat with i from 1 to the count of these_images
set the keywordslist to ""
set this_photo to item i of these_images
tell this_photo
set the image_file to the image path
set the image_title to the title
set the image_filename to the image filename
set the image_comment to the comment
set the assigned_keywords to the name of keywords
set the image_date to the date
set date_step1 to do shell script "echo " & image_date & " | sed ’s/,//g’ | sed ’s/\\([A-Z][a-z][a-z]\\)\\([a-z]\\)*/\\1/g’ | sed ’s/[0-9][0-9]\\([0-9][0-9]\\)/\\1/’"
set date_step2 to do shell script "date -j -f ‘%a %b %d %y %I:%M:%S %p’ " & quoted form of date_step1 & " ‘+%y:%m:%d %H:%M:%S’ | sed ’s/^0/200/’ | sed ’s/^9/199/’"
end tell
repeat with j from 1 to the count of assigned_keywords
set the keywordslist to keywordslist & " -keywords+=" & item j of assigned_keywords
end repeat
set the command to "exiftool -m -PL -title=\"" & image_title & ¬
"\" " & keywordslist & ¬
" " & " -comment=’" & image_comment & ¬
"’ " & " -CreateDate=’" & date_step2 & ¬
"’ " & " -DateTimeOriginal=’" & date_step2 & ¬
"’ " & " -Copyright=’" & copyright & ¬
"’ " & " -CopyrightNotice=’" & copyright & ¬
"’ " & " -Rights=’" & copyright & ¬
"’ " & " -Marked=’" & Copyrighted & ¬
"’ " & "\"" & image_file & "\""
set output to do shell script command
do shell script "rm \"" & image_file & "\"" & exifToolOriginal
set counter to counter + 1
end repeat
display dialog "Exif writing complete for " & (counter as string) & " files."
on error error_message number error_number
if the error_number is not -128 then
display dialog error_message & " Exif writing complete for " & (counter as string) & " files." buttons {"Cancel"} default button 1
end if
end try
end tell
on selected_images()
tell application "iPhoto"
try
– get selection
set these_items to the selection
– check for single album selected
if the class of item 1 of these_items is album then error
– return the list of selected photos
return these_items
on error
return false
end try
end tell
end selected_images
J’ai amélioré le script pour le rendre compatible avec les inévitables accents et apostrophes de la langue française. J’ai aussi ajouté le support pour les dates (cf. les expressions régulières et ’sed’ plus haut, lignes 33 et 34) – à noter que mes locales sont en anglais sur MacOSX donc il y aura peut-être des adaptations à faire pour retomber sur vos pieds (notamment l’usage de AM/PM serait surprenant avec des locales françaises, voir ligne 34). Petite cerise sur le gâteau, le programme retourne le nombre de fichiers modifiés (ligne 53) et éventuellement le fichier qui a causé une erreur en cas de plantage (ligne 56).
Attention : par choix personnel, j’ai décidé d’ignorer les erreurs mineures (modificateur ‘-m’ dans la commande ‘exiftool’ à la ligne 39). Il est recommandé d’essayer le script sans ce modificateur et de le rajouter si vous rencontrez des problèmes et que vous voulez tenter votre chance.
Vous pouvez télécharger le script ici : Set Exif Data




