I wanted to create an AppleScript whereby for the photos I post online, it'd remove all my exif data, change format from HEIC to JPG, and (as a bonus) resize the images. Is that possible?
And there is exiftool for scripting exif manipulation.
ExifTool by Phil Harvey
A command-line application and Perl library for reading and writing EXIF, GPS, IPTC, XMP, makernotes and other meta information in image, audio and video files. For Windows, MacOS, and Unix systems.exiftool.org
Thanks! Do you know of a Mac App Store version?Try ImageOptim https://imageoptim.com/mac
The is no App Store version of ImageOptim, but XnConvert is similar and free https://apps.apple.com/app/xnconvert/id436203431hehe299792458 said:Thanks! Do you know of a Mac App Store version?
Thanks. But do you know how to script the action I wanted above?
exiftool -all= -P mypic.jpg
exiftool -s mypic.jpg
exiftool -TAGNAME= -P mypic.jpg
cd path-to-folder-to-process
exiftool -all= -P -r -progress .
export v : Export media items to the specified location as files
export list of media item : The list of media items to export.
to file : The destination of the export.
[using originals boolean] : Export the original files if true, otherwise export rendered jpgs. defaults to false.
--https://developer.apple.com/library/archive/documentation/LanguagesUtilities/Conceptual/MacAutomationScriptingGuide/ManipulateImages.html
--https://developer.apple.com/library/archive/documentation/AppleScript/Conceptual/AppleScriptLangGuide/reference/ASLR_cmds.html
set theSourceFolder to choose folder with prompt "Please select the folder containing HEIC/HEIF files"
set theOutputFolder to choose folder with prompt "Please select an output folder"
--Source and Output can be the same folder
tell application "Finder"
set theFiles to the files of theSourceFolder
repeat with currentFile in theFiles
if name extension of currentFile is in {"HEIC", "HEIF"} then
--setting extension to hiddden in order to get only the file name
set extension hidden of currentFile to true
set theName to displayed name of currentFile
--the extension can be displayed again
--set extension hidden of currentFile to false
tell application "Image Events"
launch
set theImage to open currentFile as string
save theImage as JPEG in (theOutputFolder & theName & ".jpg" as string)
close theImage
end tell
--the original file can be moved to Trash
--delete currentFile
end if
end repeat
end tell
--This is just a visual confirmation, it can be deleted
set ConvertedFiles to do shell script "ls " & (POSIX path of theOutputFolder) & " | grep 'jpg' "
display dialog "The file(s):" & return & return & ConvertedFiles & return & return & "saved in: " & POSIX path of theOutputFolder buttons {"Close"} default button 1
--NConvert is provided as FREEWARE (NO Adware, NO Spyware) for private or educational use (including non-profit organizations). https://www.xnview.com/en/nconvert/
--NConvert for macOS http://download.xnview.com/NConvert-macosx64.tgz
set theSourceFolder to choose folder with prompt "Please select the folder containing HEIC/HEIF files"
tell application "Finder"
set theFiles to the files of theSourceFolder
repeat with currentFile in theFiles
if name extension of currentFile is in {"HEIC", "HEIF"} then
set theImage to quoted form of POSIX path of (currentFile as string)
do shell script "/Applications/NConvert/nconvert -rmeta -out jpeg " & theImage
end if
end repeat
end tell