<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Single-Serving Photo &#187; applescript</title>
	<atom:link href="http://singleservingphoto.com/tag/applescript/feed/" rel="self" type="application/rss+xml" />
	<link>http://singleservingphoto.com</link>
	<description>Photography in Small Doses</description>
	<lastBuildDate>Wed, 25 Aug 2010 13:26:16 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Automated Workflow II</title>
		<link>http://singleservingphoto.com/2007/04/19/automated-workflow-ii/</link>
		<comments>http://singleservingphoto.com/2007/04/19/automated-workflow-ii/#comments</comments>
		<pubDate>Fri, 20 Apr 2007 02:26:20 +0000</pubDate>
		<dc:creator>Aaron</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[applescript]]></category>
		<category><![CDATA[guide]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[technology]]></category>
		<category><![CDATA[workflow]]></category>

		<guid isPermaLink="false">http://www.singleservingphoto.com/2007/04/19/automated-workflow-ii/</guid>
		<description><![CDATA[	In the last chapter of my Automated Workflow series, I showed you how to use some neat scripting tricks to apply watermarks to your photos automatically. In this chapter, I&#8217;m going to talk about naming and organizing photos and show you how to set up some scripts to make things easier for you.

	You have a [...]]]></description>
			<content:encoded><![CDATA[	<p>In the <a href="http://www.singleservingphoto.com/2007/04/15/automated-workflow-i/">last chapter of my Automated Workflow series</a>, I showed you how to use some neat scripting tricks to apply watermarks to your photos automatically. In this chapter, I&#8217;m going to talk about naming and organizing photos and show you how to set up some scripts to make things easier for you.</p>

	<p>You have a bunch of pretty photos; shouldn&#8217;t they have pretty names?<span id="more-104"></span></p>

	<p>I always name my photographs. Even if the names are sometimes trite or clichéd, I think that any photo that has worked its way into the gallery deserves a name. When I put photos into <a href="http://www.fisheyegallery.com">my gallery</a>, I like to name the files themselves with the name of the photograph so that the <span class="caps">URL</span>s are pretty. It makes more sense to see a <span class="caps">URL</span> like <code>/Places/Chicago/MillenniumPark.jpg.html</code> than something ugly like <code>/plc/chg-il/chg-mp-01.jpg</code>, don&#8217;t you think?</p>

	<p>One thing I hate is to do things more than once. Isn&#8217;t that why we have computers? &#8220;So,&#8221; I thought to myself, &#8220;if I&#8217;m going to enter the names of the photos into the <code>Title</code> field of their metadata anyway,&#8221; which I do, &#8220;shouldn&#8217;t I be able to read that out somehow and name the file with it?&#8221; Yes, yes I can. This is because I am a nerd. It is this power that I will give you today. Nerd power.</p>

	<h2>Getting the Programs</h2>

	<p>First, you&#8217;re going to need a working installation of <a href="http://www.macports.org">MacPorts</a>. In my <a href="http://www.singleservingphoto.com/2007/04/15/automated-workflow-i/">previous article</a> I explained how to get that working, so go over that part again if you need to. I will assume you have it installed, even if you didn&#8217;t install the ports I talked about last time.</p>

	<p>Now install a program called <code>exiv2</code>, which is a terminal utility for reading Exif and other data out of (primarily) <span class="caps">JPEG</span> files. Installing it should be as easy as opening up your terminal program of choice and typing:</p>

	<div class="code text" style="font-family: monospace;">
airborne@Auriga ~ $ sudo port install exiv2

&nbsp;</div>

	<p>Remember, you&#8217;re only typing the part after the dollar sign. You will probably be prompted for your password and then it&#8217;ll run off and download things and install them for you. Once it&#8217;s done, make sure it worked by running the program:</p>

	<div class="code text" style="font-family: monospace;">
airborne@Auriga ~ $ exiv2<br />
exiv2: An action must be specified<br />
exiv2: At least one file is required<br />
Usage: exiv2 [ options ] [ action ] file ...<br />
<br />
Manipulate the Exif metadata of images.

&nbsp;</div>

	<p>It should look more or less like that. If you get a <code>-bash: exiv2: command not found</code> error, that&#8217;s not good, so you should look back at what MacPorts told you during the installation to find out what went wrong. Now that you have <code>exiv2</code> installed, you can use it to read information out of files. Here is what the basic output of <code>exiv2</code> looks like if you don&#8217;t specify any extra options:</p>

	<div class="code text" style="font-family: monospace;">
airborne@Auriga ~ $ exiv2 24Jun06-03.jpg <br />
Filename&nbsp; &nbsp; &nbsp; &nbsp; : 24Jun06-03.jpg<br />
Filesize&nbsp; &nbsp; &nbsp; &nbsp; : 147491 Bytes<br />
Camera make&nbsp; &nbsp; &nbsp;: Canon<br />
Camera model&nbsp; &nbsp; : Canon EOS 10D<br />
Image timestamp : 2006:06:24 17:45:27<br />
Image number&nbsp; &nbsp; : <br />
Exposure time&nbsp; &nbsp;: 1/90 s<br />
Aperture&nbsp; &nbsp; &nbsp; &nbsp; : F11<br />
Exposure bias&nbsp; &nbsp;: 0<br />
Flash&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;: No<br />
Flash bias&nbsp; &nbsp; &nbsp; : <br />
Focal length&nbsp; &nbsp; : 44.0 mm<br />
Subject distance: <br />
ISO speed&nbsp; &nbsp; &nbsp; &nbsp;: 200<br />
Exposure mode&nbsp; &nbsp;: <br />
Metering mode&nbsp; &nbsp;: Matrix<br />
Macro mode&nbsp; &nbsp; &nbsp; : <br />
Image quality&nbsp; &nbsp;: <br />
Exif Resolution : <br />
White balance&nbsp; &nbsp;: <br />
Thumbnail&nbsp; &nbsp; &nbsp; &nbsp;: None<br />
Copyright&nbsp; &nbsp; &nbsp; &nbsp;: Copyright (c) 2006 Aaron Bieber<br />
Exif comment&nbsp; &nbsp; : 

&nbsp;</div>

	<p>But wait, there&#8217;s no image name in there, only the filename! By default, <code>exiv2</code> only prints out the Exif data, not any of the <span class="caps">IPTC</span> data, which is where things like the image&#8217;s creator, <span class="caps">URL</span>, title, etc., are stored. We can tell <code>exiv2</code> to print out <span class="caps">IPTC</span> data by using the <code>-pi</code> switch. By the way, you can find out what else it can do by asking it for help with <code>exiv2 --help</code>.</p>

	<div class="code text" style="font-family: monospace;">
airborne@Auriga ~ $ exiv2 -pi 24Jun06-03.jpg <br />
Iptc.Application2.RecordVersion&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Short&nbsp; &nbsp; &nbsp; &nbsp;1&nbsp; 2<br />
Iptc.Application2.ObjectName&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;String&nbsp; &nbsp; &nbsp;17&nbsp; Onward, Upward II<br />
Iptc.Application2.Keywords&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;String&nbsp; &nbsp; &nbsp;13&nbsp; portrait ilva<br />
Iptc.Application2.Byline&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;String&nbsp; &nbsp; &nbsp;12&nbsp; Aaron Bieber<br />
Iptc.Application2.Copyright&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; String&nbsp; &nbsp; &nbsp;31&nbsp; Copyright (c) 2006 Aaron Bieber

&nbsp;</div>

	<h2>Shelling out the Name!</h2>

	<p>You can see that this <span class="caps">JPEG</span> has been given a title (in the <span class="caps">IPTC</span> spec. they call it ObjectName), a couple of keywords, a byline (the creator&#8217;s name, usually), and a copyright notice. What we want is just the value of ObjectName. We can get this with a piece of shell scripting like so:</p>

	<div class="code bash" style="font-family: monospace;">
exiv2 -pi <span style="color: #ff0000;">&quot;a-file-with-metadata.jpg&quot;</span> | grep ObjectName | cut -c <span style="color: #cc66cc;">61</span>- | tr -<span style="color: #000066;">cd</span> <span style="color: #ff0000;">&quot;[:alpha:]&quot;</span>

&nbsp;</div>

	<p>I&#8217;m not going to explain how this works; the fun of <code>bash</code> is looking up each command and figuring out how it all comes together. If you want to figure it out, I&#8217;m confident that you will. If not, that&#8217;s okay, you can still use it! Suffice it to say, that line should output <em>only</em> the title of the image, or nothing if there isn&#8217;t one. We need to save that into a little script so that it can be given a filename to work on and so it can check to make sure everything works the way it&#8217;s supposed to. To that end, here is the script:</p>

	<div class="code bash" style="font-family: monospace;">
<span style="color: #808080; font-style: italic;">#!/bin/sh</span><br />
<br />
<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#91;</span> ! -z <span style="color: #ff0000;">&quot;$1&quot;</span> &amp;&amp; -e <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span>; <span style="color: #b1b100;">then</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">EXIV=</span><span style="color: #ff0000;">&quot;/opt/local/bin/exiv2&quot;</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">TITLE=</span>`<span style="color: #0000ff;">$EXIV</span> -pi <span style="color: #ff0000;">&quot;${1}&quot;</span> <span style="color: #cc66cc;">2</span>&gt;/dev/null | grep ObjectName | cut -c <span style="color: #cc66cc;">61</span>- | tr -<span style="color: #000066;">cd</span> <span style="color: #ff0000;">&quot;[:alpha:]&quot;</span>`;<br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#91;</span> -z <span style="color: #ff0000;">&quot;$TITLE&quot;</span> <span style="color: #66cc66;">&#93;</span>; <span style="color: #b1b100;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">echo</span> <span style="color: #ff0000;">&quot;There is no title in the metadata.&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">exit</span> <span style="color: #cc66cc;">1</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; `mv <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #ff0000;">&quot;$TITLE.jpg&quot;</span>`;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">exit</span> <span style="color: #cc66cc;">0</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">fi</span><br />
<span style="color: #b1b100;">else</span><br />
&nbsp; &nbsp; <span style="color: #000066;">echo</span> <span style="color: #ff0000;">&quot;You must supply a filename and the file must exist.&quot;</span><br />
&nbsp; &nbsp; <span style="color: #000066;">exit</span> <span style="color: #cc66cc;">0</span><br />
<span style="color: #b1b100;">fi</span>

&nbsp;</div>

	<p><strong>Note:</strong> You may have to change the path to <code>exiv2</code> in the part that starts <code>EXIV=</code> if MacPorts installed it in a different place than where it is on my system. In all likelihood it&#8217;s in the same place, but you can check by running <code>which exiv2</code>. Use the path printed by that command in your script.</p>

	<p>This script takes the filename of your photograph as an argument and renames the file with that name. It also removes any non-alphanumeric characters from the title to make sure the filename will be valid. If you wanted to change spaces into hyphens instead of removing them or something else along those lines, you&#8217;d want to examine and alter the <code>tr</code> portion of the long command at the beginning.</p>

	<p>Save that script into a file and make sure it&#8217;s executable by running <code>chmod u+x yourscriptname</code>, and you&#8217;re done!</p>

	<h2>Making a Droplet</h2>

	<p>Well, almost. Wouldn&#8217;t it be handy to be able to drag and drop a bunch of photos onto an icon and have this thing rename them all at once? You bet it would. We can easily make an AppleScript droplet that will do that, just like I showed you in the previous chapter! Here&#8217;s the code:</p>

	<div class="code applescript" style="font-family: monospace;">
<span style="color: #b1b100;">on</span> <span style="color: #000066;">open</span> theObjects<br />
&nbsp; &nbsp; <span style="color: #b1b100;">repeat</span> <span style="color: #b1b100;">with</span> theObject <span style="color: #b1b100;">in</span> theObjects<br />
&nbsp; &nbsp; &nbsp; &nbsp; do shell <span style="color: #b1b100;">script</span> <span style="color: #ff0000;">&quot;~/bin/namewithtitles &quot;</span> &amp; <span style="color: #ff0000;">&quot;'&quot;</span> &amp; ¬<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#40;</span>POSIX path <span style="color: #b1b100;">of</span> theObject <span style="color: #000066;">as</span> string<span style="color: #66cc66;">&#41;</span> &amp; <span style="color: #ff0000;">&quot;'&quot;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">end</span> <span style="color: #b1b100;">repeat</span><br />
<span style="color: #b1b100;">end</span> <span style="color: #000066;">open</span>

&nbsp;</div>

	<p>Hit Save As and make sure to select &#8220;application&#8221; as the type and also make sure that the &#8220;Startup Screen&#8221; option is unchecked. You really don&#8217;t want that one.</p>

	<p>If all has gone according to plan, you should be able to drag photos onto the droplet and they should be renamed for you! Of course, they must have title information in the <span class="caps">IPTC</span> header; Lightroom calls the field Title and will export that data with your images automatically.</p>

	<p>If you felt the urge, you could integrate these AppleScript commands into the post-processing script for Lightroom that I showed you how to set up in the previous chapter. I will leave that as a challenge for the adventurous reader.</p>

	<p>Until next time, fellow photo-nerds.</p>]]></content:encoded>
			<wfw:commentRss>http://singleservingphoto.com/2007/04/19/automated-workflow-ii/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Automated Workflow I</title>
		<link>http://singleservingphoto.com/2007/04/15/automated-workflow-i/</link>
		<comments>http://singleservingphoto.com/2007/04/15/automated-workflow-i/#comments</comments>
		<pubDate>Mon, 16 Apr 2007 01:41:27 +0000</pubDate>
		<dc:creator>Aaron</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[applescript]]></category>
		<category><![CDATA[guide]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[lightroom]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[technology]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[tools]]></category>
		<category><![CDATA[workflow]]></category>

		<guid isPermaLink="false">http://www.singleservingphoto.com/2007/04/15/automated-workflow-i/</guid>
		<description><![CDATA[	Do you find yourself performing the same mundane tasks over and over? Exporting photos, sorting them, watermarking them, renaming the files, applying metadata, uploading them, etc., etc. These kinds of tasks are simply ripe for automation. Make the computer do all the work, that&#8217;s my mantra.

	In this series of articles, I will discuss the down [...]]]></description>
			<content:encoded><![CDATA[	<p>Do you find yourself performing the same mundane tasks over and over? Exporting photos, sorting them, watermarking them, renaming the files, applying metadata, uploading them, etc., etc. These kinds of tasks are simply <em>ripe</em> for automation. Make the computer do all the work, that&#8217;s my mantra.</p>

	<p>In this series of articles, I will discuss the down and dirty mechanics of how I&#8217;ve automated a good deal of my workflow. I&#8217;ll probably continue to add chapters to this series as I figure out new methods, but hopefully you can start saving time right off the bat with some of these tips!</p>

	<p>Today&#8217;s topic is <strong>exporting</strong> and <strong>watermarking</strong>.<span id="more-103"></span></p>

	<p>For starters, I&#8217;m using a Mac and I&#8217;m using Adobe Lightroom 1.0. If you use different software or a different platform, a lot of this probably won&#8217;t work for you. If you manage to port some of my automation processes to a different platform or software package, please share with me!</p>

	<p>What we&#8217;re going to do together right now is build an AppleScript application that acts as a <em>droplet</em>, which allows you to (as you might expect) <em>drop</em> image files onto it to watermark them. This droplet takes all of the overhead of Photoshop and the monotony of manual labor out of the watermarking process, which I think you will come to love as much as I do.</p>

	<p>As a bonus, we can set up Adobe Lightroom to use this droplet as a post-processing filter (and I&#8217;ll show you how!), so the activity of applying a custom watermark to your images becomes tightly integrated into the activity of exporting from Lightroom. If you don&#8217;t have Lightroom, or don&#8217;t even <em>like</em> Lightroom, you can still use the AppleScript droplet to watermark a bunch of photos at once.</p>

	<p>The first step is&#8230;</p>

	<h2>Building the Watermark</h2>

	<p>The first step in automating the watermark process is to have a watermark graphic you want to use. You will need a standalone graphic file that will work in any photo scenario. In other words, if your watermark uses transparency and the text is white, you probably won&#8217;t be able to read it if it&#8217;s applied to a very light photo.</p>

	<p>For my watermark, I have gone with a very small and very controlled image, which I&#8217;ve named simply <code>copyright.gif</code>:</p>

	<p><img src="/articles/AutomationI/copyright.gif" alt="" width="310" height="9" /></p>

	<p>The only technical considerations when composing a watermark image are:</p>

	<ul>
		<li>It should be narrower than the smallest for-web image you will export, so that it isn&#8217;t cut off. I always export my images for this blog at 600 pixels wide, so I&#8217;m safe with this watermark (which is 310 pixels wide).</li>
		<li>It should be legible on any image, regardless of the image&#8217;s lightness or darkness. To solve this problem, I&#8217;ve used a black background. I experimented with different approaches and found this one to be the most reliable, even if not always the most attractive.</li>
	</ul>

	<p>Now that we have a workable watermark image, it&#8217;s time to&#8230;</p>

	<h2>Install ImageMagick</h2>

	<p>ImageMagick is a command-line image manipulation suite originally developed in the Linux community. It&#8217;s free, powerful, and could serve you in more ways than watermarking, so let&#8217;s get this thing installed! The easiest way to install ImageMagick is through the package management system called MacPorts (formerly known as DarwinPorts).</p>

	<p>Pop over to <a href="http://www.macports.org/">MacPorts</a> and download the latest version. You install MacPorts in the same way you&#8217;d install any other Mac application: open the .dmg file, run the installer, wait a while, and there you have it. Now that MacPorts is installed, it&#8217;s time to delve into darker territories: <strong>the terminal</strong>. If you are unfamiliar with the terminal, don&#8217;t be too intimidated; I&#8217;ll show you exactly what to type.</p>

	<p>Open up the terminal (the default Terminal application or your choice of <a href="http://iterm.sf.net">replacement terminal</a>) and make sure MacPorts is working properly:</p>

	<div class="code text" style="font-family: monospace;">
airborne@Auriga ~ $ port

&nbsp;</div>

	<p><em>Note that your prompt will look different than mine; the only part you need to type is</em> <code>port</code>. Press return and, if everything has gone according to plan, you should see the default output of the <code>port</code> program:</p>

	<div class="code text" style="font-family: monospace;">
Usage: port [-vdqfonasbcktu] [-D portdir] action [actionflags]<br />
[[portname|pseudo-portname|port-url] [@version] [+-variant]... [option=value]...]...<br />
<br />
&quot;port help&quot; or &quot;man 1 port&quot; for more information.

&nbsp;</div>

	<p>Installing ImageMagick should be as simple as:</p>

	<div class="code text" style="font-family: monospace;">
airborne@Auriga ~ $ sudo port install imagemagick

&nbsp;</div>

	<p>The <code>sudo</code> command allows you to run a program as the superuser, which is required in order to install things into locations within the OS X system folders (much the same as entering your password when running certain installer packages). You will be prompted for <em>your</em> password; enter it and press return. It will take some time to download the required files, decompress them, etc., etc. When it&#8217;s done, it will let you know. If you get any errors along the way, you will want to refer to the <a href="http://www.macports.org">MacPorts website</a> or search on the Internet for solutions; fixing MacPorts problems is too vast an area to cover in this article.</p>

	<p>You can now confirm that ImageMagick is installed by trying to run one of its included tools, <code>convert</code>. Just type that in and see what happens:</p>

	<div class="code text" style="font-family: monospace;">
airborne@Auriga ~ $ convert

&nbsp;</div>

	<p>A whole bunch of stuff should print out. Don&#8217;t worry about reading it. If you get an error message like <code>-bash: convert: command not found</code> then try closing and re-opening the terminal. If it doesn&#8217;t work after that, well, something must have gone wrong with the installation and you should try to figure out what that is. There are a lot of resources available through the <a href="http://www.macports.org/">MacPorts</a> site and through The Google to help you out.</p>

	<p>Now that we have ImageMagic set up, we need to write some&#8230;</p>

	<h2>AppleScript</h2>

	<p>I love AppleScript. What we&#8217;re going to do now is write a small script (or &#8220;droplet&#8221;) that opens images and places your watermark image on them. Here is the code:</p>

	<div class="code applescript" style="font-family: monospace;">
<span style="color: #b1b100;">on</span> <span style="color: #000066;">open</span> theObjects<br />
&nbsp; &nbsp; <span style="color: #b1b100;">repeat</span> <span style="color: #b1b100;">with</span> theObject <span style="color: #b1b100;">in</span> theObjects<br />
&nbsp; &nbsp; &nbsp; &nbsp; do shell <span style="color: #b1b100;">script</span> <span style="color: #ff0000;">&quot;/opt/local/bin/composite -compose Over &quot;</span> &amp; ¬<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">&quot;-gravity southwest /Users/airborne/Pictures/copyright.gif '&quot;</span> &amp; ¬<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#40;</span>POSIX path <span style="color: #b1b100;">of</span> theObject <span style="color: #000066;">as</span> string<span style="color: #66cc66;">&#41;</span> &amp; <span style="color: #ff0000;">&quot;' '&quot;</span> &amp; <span style="color: #66cc66;">&#40;</span>POSIX path <span style="color: #b1b100;">of</span> theObject <span style="color: #000066;">as</span> string<span style="color: #66cc66;">&#41;</span> &amp; <span style="color: #ff0000;">&quot;'&quot;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">end</span> <span style="color: #b1b100;">repeat</span><br />
<span style="color: #b1b100;">end</span> <span style="color: #000066;">open</span>

&nbsp;</div>

	<p><strong>Beware</strong>. I have broken up a couple of the lines to make it appear properly on the blog. The linebreak character, which should look like the upper right corner of a square, might not appear properly in your browser.</p>

	<p>If you want, you can just <a href="/articles/AutomationI/Watermark.app">download the script</a> from my site. You should be able to open this file in Script Editor and change the paths to suit your environment (mostly change the path to your watermark file), and in fact, you <em>must change this path</em> or the script will not work. In the above code, <code>/Users/airborne/Pictures/copyright.gif</code> is the part you need to change.</p>

	<p>I will now explain the code in greater detail for anyone interested. If you couldn&#8217;t care less how it works, skip the next couple of paragraphs. The first part, <code>on open theObjects</code> means that this script expects to be opened with files passed into it, either by dragging and dropping files onto its icon in the Finder, or by being triggered from Lightroom, et al. (Image Capture can also use post-import scripts and they work in precisely the same way). When the script runs, <code>theObjects</code> will be a list of files to do something with.</p>

	<p>The following block (<code>repeat with</code>) is then repeated with each file that was passed in. The <code>composite</code> program included in ImageMagick is used to layer an image on top of another image, so we call that with the <code>do shell script</code> command, which basically simulates typing something into the terminal. The <code>-compose Over</code> option tells it to place the second image on top of the first, and <code>-gravity southwest</code> means to place it in the lower left corner. I then supply the paths to my <code>copyright.gif</code> and the <span class="caps">POSIX</span> path of each of the files opened by this script (the ones dropped onto its icon or passed in by Lightroom). If any of this is unclear, leave a comment.</p>

	<p>If you are re-creating this script for yourself, just be sure to save it as an application. In the &#8220;save&#8221; dialog, you can choose a few different formats to save the script in, but only &#8220;application&#8221; will give it the ability to operate as a droplet (a program you can drop files onto).</p>

	<p>Great, now let&#8217;s make it run automatically from Lightroom!</p>

	<h2>Configuring Lightroom</h2>

	<p>When you run the Export command from Lightroom, you are presented with a dialog box much like the one you see below. We are chiefly concerned with the option highlighted in this picture.</p>

	<p><img src="/articles/AutomationI/Figure-1.jpg" alt="" width="600" height="637" /></p>

	<p>When you open that menu, you will want to choose &#8220;Go to Export Actions Folder Now&#8221; as shown below.</p>

	<p><img src="/articles/AutomationI/Figure-2.jpg" alt="" width="585" height="186" /></p>

	<p><em>Note: disregard the &#8220;Watermark+Upload&#8221; option; that is a modified version of this Watermark script that also opens Transmit and uploads the photos to my website. I&#8217;ll cover that functionality in another article. See, AppleScript rules!</em></p>

	<p>When you choose that option, the Export Actions folder will be revealed in the Finder and you can then place the Watermark script into it. Make sure it&#8217;s <strong>in</strong> the Export Actions folder and not in the Lightroom folder! If you cancel and re-open the Export dialog, you will now be able to select Watermark in the list. Exporting photos using that post-processing filter should now automatically apply your watermark image!</p>

	<p>This has been a long-winded and very technical article. I realize that all of you are coming here with different levels of familiarity with the terminal, ImageMagick, AppleScript, etc., so I covered what I thought were the most important points. If you have any questions, just leave a comment and I&#8217;ll be glad to explain anything I left out.</p>

	<p>Good luck and happy watermarking!</p>

	<p>P.S. Learn even more about scripting in <a href="/2007/04/19/automated-workflow-ii/">Automated Workflow II</a></p>]]></content:encoded>
			<wfw:commentRss>http://singleservingphoto.com/2007/04/15/automated-workflow-i/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
