Remove from EXIF – удаление из фотографии информации о камере и объективе

Иногда вы не хотите оставлять в файле информацию о том, каким объективом и какой „тушкой“ была сделана фотография. Эти данные можно удалить из EXIF с помощью exiftool, оставив все остальные метаданные – локацию, параметры съёмки и т.п.

Чтобы упростить эту задачу, я написал небольшое приложение-службу для macOS, которое запускается из контекстного меню. Вы кликаете по фотографии правой кнопкой мыши и выбираете, какую информацию убрать из EXIF:

Remofe from EXIF...
Диалоговое окно Remofe from EXIF...

Чтобы реализовать на своём Mac аналогичную функцию, создайте службу Automator (Service) с именем Remove from EXIF....workflow в папке
~/Library/Services
Пусть она будет применяться только к изображениям или к файлам и папкам – на ваш выбор.

Далее перетаскиваем в окно Automator элемент Run AppleScript, и заполняем его следующим кодом:
property preferences_file : "com.pozhvanov.exifcl.plist"
property preferences_path : "~/Library/Preferences/"
property exiftool_path : "/usr/local/bin/exiftool"
property RemoveCameraInfo : "-Make=\"\" -model=\"\""
property RemoveLensInfo : "-Lens=\"\" -LensID=\"\" -FocalLength=\"\" -LensInfo=\"\" -LensSerialNumber=\"\" -LensModel=\"\""
property askForOptions_label : "Please select which type of EXIF record to remove:"
property RemoveCameraInfo_label : "Camera body"
property RemoveLensInfo_label : "Lens"
property RemoveBoth_label : "Both"
property RemoveCancel_label : "Cancel"

to checkPreferences()
  tell application "System Events"
    if exists file preferences_file of (path to preferences from user domain) then
      return 1
    else
      return 0
    end if
  end tell
end checkPreferences

to EditEXIF(ImageFile, processOptions)
  local ScriptString
  set ScriptString to exiftool_path & " -overwrite_original_in_place -P"
  if processOptions contains {RemoveCameraInfo_label} or processOptions contains {RemoveBoth_label} then
    set ScriptString to ScriptString & " " & RemoveCameraInfo
  end if
  if processOptions contains {RemoveLensInfo_label} or processOptions contains {RemoveBoth_label} then
    set ScriptString to ScriptString & " " & RemoveLensInfo
  end if
  set ScriptString to ScriptString & " " & "\"" & POSIX path of (ImageFile as text)
& "\""
  #  display notification ScriptString
  do shell script ScriptString
end EditEXIF

to setOptions()
  return choose from list {RemoveCameraInfo_label, RemoveLensInfo_label} with title "set options" with prompt "Please select which type of EXIF record to remove:" OK button name "Next" with multiple selections allowed without empty selection allowed
end setOptions

on run {input, parameters}
  set def_btn to RemoveCameraInfo_label
  (*  Read preferences from Preferences File  *)
  if checkPreferences() is equal to 1 then
    set the exifcl_plist to preferences_path & preferences_file
    tell application "System Events"
      tell property list file exifcl_plist
        tell contents
          if exists property list item "last_selected_button" then
            set def_btn to value of property list item "last_selected_button"
          end if
        end tell
      end tell
    end tell
  end if
  
  set askForOptions to display dialog askForOptions_label buttons {RemoveCameraInfo_label, RemoveLensInfo_label, RemoveBoth_label} default button def_btn
  set processOptions to (button returned of askForOptions)
  #  set processOptions to setOptions()
  if processOptions is not false then
    repeat with i in input as list
      EditEXIF(i, processOptions)
      #      display notification i as text with title "Remove EXIF info"
    end repeat
  end if
  
  tell application "System Events"
    set exifcl_dictionary to make new property list item with properties {kind:record}
    set exifcl_plist to preferences_path & preferences_file
    set this_plist to make new property list file with properties {contents:exifcl_dictionary, name:exifcl_plist}
    make new property list item at end of property list items of contents of this_plist
with properties {kind:string, name:"last_selected_button", value:{processOptions}}
  end tell
  
  if (count of input) as integer is less than 2 then
    display notification "EXIF data were altered in " & ((count of input) as string) & " file." with title "Remove EXIF info"
    
  else
    display notification "EXIF data were altered in " & ((count of input) as string) & " files." with title "Remove EXIF info"
  end if
end run

Добавить комментарий