<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" 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:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">
<channel>
	<title>Comments for Erik's Lab</title>
	
	<link>http://erikslab.com</link>
	<description>Things I'm working on, not necessarily functioning yet.</description>
	<lastBuildDate>Wed, 17 Feb 2010 17:07:13 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/CommentsForEriksLab" /><feedburner:info uri="commentsforerikslab" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:browserFriendly></feedburner:browserFriendly><item>
		<title>Comment on OS X: Getting Image-Dimensions on the Command-Line (sips) by Jamie</title>
		<link>http://erikslab.com/2008/03/09/os-x-getting-image-dimensions-on-the-command-line-sips/comment-page-1/#comment-92</link>
		<dc:creator>Jamie</dc:creator>
		<pubDate>Wed, 17 Feb 2010 17:07:13 +0000</pubDate>
		<guid isPermaLink="false">http://erikslab.com/2008/03/09/os-x-getting-image-dimensions-on-the-command-line-sips/#comment-92</guid>
		<description>sips is very useful but also frustratingly not quite powerful enough at times.

1. When getting image size info it's often useful to have the data in a spreadsheet to highlight images below a certain size. Ideally sips would therefore output "filename \t width \t height", i.e. one line per file, with each piece of information separated by tabs.

At the moment I've directed the output to a file (e.g. sips -g pixelWidth -g pixelHeight [image-file] &gt; results.txt) then opened in TextWrangler and done some find and replace operations:
a) Find pixelWidth, plus the line break and spaces before and the space after. Replace with \t (in TextEdit press alt and tab)
b) Do the same for the pixelHeight.

You could probably do this find and replace on the command line. This example gives an idea, although it does not work because sed doesn't recognise the \n and \t characters.
sips -g pixelWidth -g pixelHeight /path/to/folder/* | sed -E "/\n(  pixelWidth: |  pixelHeight: )/s//\t/" &gt; /path/to/textfile.txt

2. The --resampleHeightWidthMax option is useful to make an image fit within a certain size such as 160 pixels. But if you want to fit the image within a rectangular shape such as 120x160 you can't. Using both --resampleWidth and --resampleHeight options together gives some odd results, although doesn't seem to stretch the picture even though the man page suggests it will.

3. It doesn't work with EPS files. You need to use pstopdf first.

4. The pad images option always centres the image within the padded area. There's no way to change this.

Many of sips' features are accessible via Automator, too, such as the Pad Images command. If you need to use the command line sips tool via Automator, add a Run Shell Script action that takes input 'as arguments' and does something like this:

for f in "$@"
do
	sips --addIcon --setProperty format tiff --setProperty formatOptions best --setProperty formatOptions lzw  --resampleHeightWidthMax 160 "$f" --out "`dirname "$f"`/`basename "$f"|cut -d '.' -f1`".tiff
done

This takes the current item Automator is looking at, makes a TIFF no bigger than 160x160 and outputs it with the same filename as the original but with .tiff on the end.</description>
		<content:encoded><![CDATA[<p>sips is very useful but also frustratingly not quite powerful enough at times.</p>
<p>1. When getting image size info it&#8217;s often useful to have the data in a spreadsheet to highlight images below a certain size. Ideally sips would therefore output &#8220;filename \t width \t height&#8221;, i.e. one line per file, with each piece of information separated by tabs.</p>
<p>At the moment I&#8217;ve directed the output to a file (e.g. sips -g pixelWidth -g pixelHeight [image-file] &gt; results.txt) then opened in TextWrangler and done some find and replace operations:<br />
a) Find pixelWidth, plus the line break and spaces before and the space after. Replace with \t (in TextEdit press alt and tab)<br />
b) Do the same for the pixelHeight.</p>
<p>You could probably do this find and replace on the command line. This example gives an idea, although it does not work because sed doesn&#8217;t recognise the \n and \t characters.<br />
sips -g pixelWidth -g pixelHeight /path/to/folder/* | sed -E &#8220;/\n(  pixelWidth: |  pixelHeight: )/s//\t/&#8221; &gt; /path/to/textfile.txt</p>
<p>2. The &#8211;resampleHeightWidthMax option is useful to make an image fit within a certain size such as 160 pixels. But if you want to fit the image within a rectangular shape such as 120&#215;160 you can&#8217;t. Using both &#8211;resampleWidth and &#8211;resampleHeight options together gives some odd results, although doesn&#8217;t seem to stretch the picture even though the man page suggests it will.</p>
<p>3. It doesn&#8217;t work with EPS files. You need to use pstopdf first.</p>
<p>4. The pad images option always centres the image within the padded area. There&#8217;s no way to change this.</p>
<p>Many of sips&#8217; features are accessible via Automator, too, such as the Pad Images command. If you need to use the command line sips tool via Automator, add a Run Shell Script action that takes input &#8216;as arguments&#8217; and does something like this:</p>
<p>for f in &#8220;$@&#8221;<br />
do<br />
	sips &#8211;addIcon &#8211;setProperty format tiff &#8211;setProperty formatOptions best &#8211;setProperty formatOptions lzw  &#8211;resampleHeightWidthMax 160 &#8220;$f&#8221; &#8211;out &#8220;`dirname &#8220;$f&#8221;`/`basename &#8220;$f&#8221;|cut -d &#8216;.&#8217; -f1`&#8221;.tiff<br />
done</p>
<p>This takes the current item Automator is looking at, makes a TIFF no bigger than 160&#215;160 and outputs it with the same filename as the original but with .tiff on the end.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on My DocBook-Bundle for TextMate by Jason Jansma » XML the Easy Way</title>
		<link>http://erikslab.com/2008/02/26/my-docbook-bundle-for-textmate/comment-page-1/#comment-89</link>
		<dc:creator>Jason Jansma » XML the Easy Way</dc:creator>
		<pubDate>Fri, 03 Jul 2009 17:26:47 +0000</pubDate>
		<guid isPermaLink="false">http://erikslab.com/2008/02/26/my-docbook-bundle-for-textmate/#comment-89</guid>
		<description>[...] TextMate has a built-in XML bundle; however, if you are using DocBook XML, then you should use one of the free DocBook [...]</description>
		<content:encoded><![CDATA[<p>[...] TextMate has a built-in XML bundle; however, if you are using DocBook XML, then you should use one of the free DocBook [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Date-/Time-Calculations using AppleScript by Erik</title>
		<link>http://erikslab.com/2007/11/26/date-time-calculations-using-applescript/comment-page-1/#comment-88</link>
		<dc:creator>Erik</dc:creator>
		<pubDate>Thu, 02 Jul 2009 07:33:12 +0000</pubDate>
		<guid isPermaLink="false">http://erikslab.com/2007/11/26/date-time-calculations-using-applescript/#comment-88</guid>
		<description>Scott, let me think about this. There are a couple of solutions popping into my head right now. I'll write a post about the subject.</description>
		<content:encoded><![CDATA[<p>Scott, let me think about this. There are a couple of solutions popping into my head right now. I&#8217;ll write a post about the subject.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Date-/Time-Calculations using AppleScript by Scott</title>
		<link>http://erikslab.com/2007/11/26/date-time-calculations-using-applescript/comment-page-1/#comment-87</link>
		<dc:creator>Scott</dc:creator>
		<pubDate>Tue, 30 Jun 2009 20:34:59 +0000</pubDate>
		<guid isPermaLink="false">http://erikslab.com/2007/11/26/date-time-calculations-using-applescript/#comment-87</guid>
		<description>so I'm trying to write and applescript to compare the create and modified time stamps of a file 
so I'm talking about a format like
2009-03-09 18:03:47 -0400
and
2009-03-09 15:03:47 -0700

which are for all intents and purposes are equal, but apple script wont let me cast them as date type.  are there any built-ins or tricks for evaluating this kind of format with applescript or even the date command from a terminal?

thanks</description>
		<content:encoded><![CDATA[<p>so I&#8217;m trying to write and applescript to compare the create and modified time stamps of a file<br />
so I&#8217;m talking about a format like<br />
2009-03-09 18:03:47 -0400<br />
and<br />
2009-03-09 15:03:47 -0700</p>
<p>which are for all intents and purposes are equal, but apple script wont let me cast them as date type.  are there any built-ins or tricks for evaluating this kind of format with applescript or even the date command from a terminal?</p>
<p>thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on OS X: Mail.app Logging by Overcoming Mail.app’s lack of verbosity « Geek Foibles</title>
		<link>http://erikslab.com/2007/07/16/os-x-mailapp-logging/comment-page-1/#comment-86</link>
		<dc:creator>Overcoming Mail.app’s lack of verbosity « Geek Foibles</dc:creator>
		<pubDate>Tue, 21 Apr 2009 08:35:33 +0000</pubDate>
		<guid isPermaLink="false">http://erikslab.com/2007/07/16/os-x-mailapp-logging/#comment-86</guid>
		<description>[...] a bit of googling, I finally came across a post on Erik’s Lab that explained how to sniff any Mail.app communications, regardless of encryption.  Apparently [...]</description>
		<content:encoded><![CDATA[<p>[...] a bit of googling, I finally came across a post on Erik&#8217;s Lab that explained how to sniff any Mail.app communications, regardless of encryption.  Apparently [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on How to convert an “epoch”-time to a meaningful date and time by hubionmac.com » Unix Epoch Timestamp zu AppleScript Datum</title>
		<link>http://erikslab.com/2006/09/05/how-to-convert-an-epoch-time-to-a-meaningful-date-and-time/comment-page-1/#comment-84</link>
		<dc:creator>hubionmac.com » Unix Epoch Timestamp zu AppleScript Datum</dc:creator>
		<pubDate>Thu, 19 Mar 2009 23:45:04 +0000</pubDate>
		<guid isPermaLink="false">http://erikslab.com/2006/09/05/how-to-convert-an-epoch-time-to-a-meaningful-date-and-time/#comment-84</guid>
		<description>[...] für ein Script Unix-Zeitstempel in ein Apple-Script-Datum konvertieren, und fand bei einer Suche diesen QuelleCode, der anscheinend nur unter englischen System funktioniert.... Nun, deshalb habe ich mir meine [...]</description>
		<content:encoded><![CDATA[<p>[...] für ein Script Unix-Zeitstempel in ein Apple-Script-Datum konvertieren, und fand bei einer Suche diesen QuelleCode, der anscheinend nur unter englischen System funktioniert&#8230;. Nun, deshalb habe ich mir meine [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Date-/Time-Calculations using AppleScript by stib</title>
		<link>http://erikslab.com/2007/11/26/date-time-calculations-using-applescript/comment-page-1/#comment-83</link>
		<dc:creator>stib</dc:creator>
		<pubDate>Wed, 14 Jan 2009 02:11:51 +0000</pubDate>
		<guid isPermaLink="false">http://erikslab.com/2007/11/26/date-time-calculations-using-applescript/#comment-83</guid>
		<description>per:
set mM to (month of (current date)) as integer
will do it</description>
		<content:encoded><![CDATA[<p>per:<br />
set mM to (month of (current date)) as integer<br />
will do it</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Date-/Time-Calculations using AppleScript by stib</title>
		<link>http://erikslab.com/2007/11/26/date-time-calculations-using-applescript/comment-page-1/#comment-82</link>
		<dc:creator>stib</dc:creator>
		<pubDate>Wed, 14 Jan 2009 01:29:25 +0000</pubDate>
		<guid isPermaLink="false">http://erikslab.com/2007/11/26/date-time-calculations-using-applescript/#comment-82</guid>
		<description>Oh I got it. I had the shell scripts in a subroutine and was doing
 on readdate()
  set lastopen to do shell script (”defaults read org.pureandapplied.startupscript ‘lastopen’”)
  return lastopen
 end

But for some reason the subroutine doesn't get evaluated as a date. If I force it to return a date it works, so I use
 return date lastopen
not 
 return lastopen</description>
		<content:encoded><![CDATA[<p>Oh I got it. I had the shell scripts in a subroutine and was doing<br />
 on readdate()<br />
  set lastopen to do shell script (”defaults read org.pureandapplied.startupscript ‘lastopen’”)<br />
  return lastopen<br />
 end</p>
<p>But for some reason the subroutine doesn&#8217;t get evaluated as a date. If I force it to return a date it works, so I use<br />
 return date lastopen<br />
not<br />
 return lastopen</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Date-/Time-Calculations using AppleScript by stib</title>
		<link>http://erikslab.com/2007/11/26/date-time-calculations-using-applescript/comment-page-1/#comment-81</link>
		<dc:creator>stib</dc:creator>
		<pubDate>Wed, 14 Jan 2009 01:23:48 +0000</pubDate>
		<guid isPermaLink="false">http://erikslab.com/2007/11/26/date-time-calculations-using-applescript/#comment-81</guid>
		<description>I even tried adding the -date switch to the defaults command, but it seems to use a different format</description>
		<content:encoded><![CDATA[<p>I even tried adding the -date switch to the defaults command, but it seems to use a different format</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Date-/Time-Calculations using AppleScript by stib</title>
		<link>http://erikslab.com/2007/11/26/date-time-calculations-using-applescript/comment-page-1/#comment-80</link>
		<dc:creator>stib</dc:creator>
		<pubDate>Wed, 14 Jan 2009 01:14:30 +0000</pubDate>
		<guid isPermaLink="false">http://erikslab.com/2007/11/26/date-time-calculations-using-applescript/#comment-80</guid>
		<description>I'm trying to write a simple app for my start up folder that checks to see whether this is the first time I've booted up today so it can open stuff that I need when I first get in to work, but which I don't want to see if I restart during the day.

I do it by getting the app to store the last login date in my preferences, and compare the last login with today. But If I do

do shell script ("defaults write org.pureandapplied.startupscript 'lastopen' '" &amp; (current date) &amp; "'")
set lastopen to do shell script ("defaults read org.pureandapplied.startupscript 'lastopen'")
day of lastopen

it doesn't treat the value returned as a date:
"Can't make \"Wednesday, 14 January 2009 12:05:29 PM\" into type date."

I can do it with text munging, or by checking the modification date on a file, but that's nowhere near as elegant.</description>
		<content:encoded><![CDATA[<p>I&#8217;m trying to write a simple app for my start up folder that checks to see whether this is the first time I&#8217;ve booted up today so it can open stuff that I need when I first get in to work, but which I don&#8217;t want to see if I restart during the day.</p>
<p>I do it by getting the app to store the last login date in my preferences, and compare the last login with today. But If I do</p>
<p>do shell script (&#8220;defaults write org.pureandapplied.startupscript &#8216;lastopen&#8217; &#8216;&#8221; &amp; (current date) &amp; &#8220;&#8216;&#8221;)<br />
set lastopen to do shell script (&#8220;defaults read org.pureandapplied.startupscript &#8216;lastopen&#8217;&#8221;)<br />
day of lastopen</p>
<p>it doesn&#8217;t treat the value returned as a date:<br />
&#8220;Can&#8217;t make \&#8221;Wednesday, 14 January 2009 12:05:29 PM\&#8221; into type date.&#8221;</p>
<p>I can do it with text munging, or by checking the modification date on a file, but that&#8217;s nowhere near as elegant.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
