Back in 2011 I wrote a blog post explaining how to create an OS X Service for stripping keywords from image files. In this post we’ll use the same technique to create a Service for stripping geotags from JPEG images.

As with the keyword stripping service, there are two prerequisites for this action, one is required, one is optional. You absolutely MUST have install EXIFTool installed, and it would be good if you also had Growl installed, but it’s not essential.

Start by opening Automator, and creating a new Service workflow.

Create New Service Workflow in Automator

At the top of the new service workflow, alter the settings so the services takes as it’s input Image Files and that the service is available in just the Finder.

Set The Service to Accept Image Files in Finder

Find the Run Shell Script action and drag and drop it into the workflow (you’ll find the action in the Utilities category, or by searching in the search bar). Change the Shell option at the top of the Run Shell Script action to /usr/bin/perl, and the Pass input option to as arguments.

To do the actual work we will add the following perl code into the action:

foreach my $image (@ARGV) {
	$image = quote_file_name($image);
	`/usr/bin/exiftool -geotag= -overwrite_original $image`;

# utility function to sanitise file names for use when shelling out
sub quote_file_name{
    my $file = shift;
    $file =~ s/([`"\\\$])/\\$1/g;
    return '"'.$file.'"';

Finally, it would be very helpful to have the service tell us when it is finished, so this is where Growl comes in. If you have it installed, drag and drop a Show Growl Notification into the workflow and enter a message of your choice.

Your Service should now look something like the screenshot below. You can now go ahead and save the Service and give it a sensible name like Strip Geotag.

Screenshot of the finished Service

You should now be able to use the service by right-clicking on a file in the Finder and choosing your new service from the Services section. If you have only a few services installed they will be shown at the bottom of the contextual menu, if you have more, they will show in a sub-menu titled Services.

The Service in Use in the Finder

I’ve included a zipped version of my service below. This service uses the Growl action, so if you don’t have Growl installed you’ll need to open the Service in Automator and remove the Growl action before you can use the Service.