Monday, October 11, 2010

EXIF data JPEG extractor for MacOSX

Sometimes there is a task to remove all EXIF data from JPEG photos you did by your photo camera. This could be useful if you're going to publish them in the net. As many knows there are professional software solutions for that. It could be Adobe® Lightroom or something else. Sure, professional solutions always costs money. Now I'm going to explain the way by which you can do the same action for free. But as in our life you have to pay for it anyway by your time to study Mac OS system. The information below is for advanced users. Current action and droplet AppleScript was tested by me on Mac OS 10.6.4 Here is how.
In addition to EXIF extraction I'd like to show you the program trick which allow to use UNIX commands inside droplet AppleScript. As old UNIX geek I can't live without console and useful UNIX CLI applications. I use it on Linux, Mac OS and even MS Windows. The installation is differ from system to system. For Mac OS I use HomeBrew. This is a great system based on 'Git'. My respect to 'The Apple Geek' @ctrld. I've known about HomeBrew from him. And my thanks and respect to Max Howell @mxcl. Won't explain how to install CLI applications by HomeBrew, because it is easy to find on official site of this great program. You need to install 'jhead' by HomeBrew before you start AppleScript code.
The code is posted below. Just copy it into your AppleScript Editor, compile and save it a application. Then you can drop your photos on it by mouse. All EXIF information will be extracted for them.
The HomeBrew system install all applications in own directory and add the /usr/local/bin path to the system path in home .profile If you plan to use MacPorts system for your CLI applications, the path for program will be differ from HomeBrew installation. The problem is that AppleScript does not accept the information from .profile file and use only system path record. Think that is because of the security reasons. As one of solution is to use the direct path for program in AppleScript. But every serious programmer will say: "Never use direct paths in code". The reason is that if you try run such script on other system or try use MacPorts instead HomeBrew it won't work. The exit from such situation is easy. Have a look onto my screenshot. Add `source ~/.profile;' before the program you plan to start. By this you tell your script to use the path from your home .profile file. That was the key point of my current article.
UPDATE: If you would like to autorotate your photos by EXIF rotate flag before remove it, just add the `-autorot' parameter into the code. See screenshot and code below.
The AppleScript:
(*Erase the EXIF information from your JPG photos by Droplet script*)
# Author is DimiG
on open these_items
  repeat with i from 1 to the count of these_items
    set this_item to item i of these_items
    tell application "Finder" to reveal this_item
    set this_path to the quoted form of the POSIX path of this_item
    do shell script "source ~/.profile; jhead -autorot -purejpg" & space & this_path
  end repeat
end open

No comments: