<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	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/"
		>
<channel>
	<title>Comments on: OS X: Getting Image-Dimensions on the Command-Line (sips)</title>
	<atom:link href="http://erikslab.com/2008/03/09/os-x-getting-image-dimensions-on-the-command-line-sips/feed/" rel="self" type="application/rss+xml" />
	<link>http://erikslab.com/2008/03/09/os-x-getting-image-dimensions-on-the-command-line-sips/</link>
	<description>Things I'm working on, not necessarily functioning yet.</description>
	<lastBuildDate>Sat, 02 Apr 2011 22:40:30 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
	<item>
		<title>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&#039;s often useful to have the data in a spreadsheet to highlight images below a certain size. Ideally sips would therefore output &quot;filename \t width \t height&quot;, i.e. one line per file, with each piece of information separated by tabs.

At the moment I&#039;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&#039;t recognise the \n and \t characters.
sips -g pixelWidth -g pixelHeight /path/to/folder/* &#124; sed -E &quot;/\n(  pixelWidth: &#124;  pixelHeight: )/s//\t/&quot; &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&#039;t. Using both --resampleWidth and --resampleHeight options together gives some odd results, although doesn&#039;t seem to stretch the picture even though the man page suggests it will.

3. It doesn&#039;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&#039;s no way to change this.

Many of sips&#039; 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 &#039;as arguments&#039; and does something like this:

for f in &quot;$@&quot;
do
	sips --addIcon --setProperty format tiff --setProperty formatOptions best --setProperty formatOptions lzw  --resampleHeightWidthMax 160 &quot;$f&quot; --out &quot;`dirname &quot;$f&quot;`/`basename &quot;$f&quot;&#124;cut -d &#039;.&#039; -f1`&quot;.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>By: Erik</title>
		<link>http://erikslab.com/2008/03/09/os-x-getting-image-dimensions-on-the-command-line-sips/comment-page-1/#comment-38</link>
		<dc:creator>Erik</dc:creator>
		<pubDate>Fri, 28 Mar 2008 10:43:57 +0000</pubDate>
		<guid isPermaLink="false">http://erikslab.com/2008/03/09/os-x-getting-image-dimensions-on-the-command-line-sips/#comment-38</guid>
		<description>Hi Martin,
thanks for the info. I wasn&#039;t aware that &quot;Image Events&quot; is using sips.

BTW: Sorry for answering so late, I&#039;ve been very busy the last couple of weeks.</description>
		<content:encoded><![CDATA[<p>Hi Martin,<br />
thanks for the info. I wasn&#8217;t aware that &#8220;Image Events&#8221; is using sips.</p>
<p>BTW: Sorry for answering so late, I&#8217;ve been very busy the last couple of weeks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Martin Michel</title>
		<link>http://erikslab.com/2008/03/09/os-x-getting-image-dimensions-on-the-command-line-sips/comment-page-1/#comment-33</link>
		<dc:creator>Martin Michel</dc:creator>
		<pubDate>Sun, 09 Mar 2008 11:01:23 +0000</pubDate>
		<guid isPermaLink="false">http://erikslab.com/2008/03/09/os-x-getting-image-dimensions-on-the-command-line-sips/#comment-33</guid>
		<description>Hi Erik,

I just wanted to add, that AppleScript has its own built-in sips-based scripting addition named Image Events.

Image Events is basically just a wrapper for sips. So when scripting in AppleScript, there is often no need to use sips via the «do shell script» command, you can just gain informations or manipulate images with Image Events.

Best regards from Germany!</description>
		<content:encoded><![CDATA[<p>Hi Erik,</p>
<p>I just wanted to add, that AppleScript has its own built-in sips-based scripting addition named Image Events.</p>
<p>Image Events is basically just a wrapper for sips. So when scripting in AppleScript, there is often no need to use sips via the «do shell script» command, you can just gain informations or manipulate images with Image Events.</p>
<p>Best regards from Germany!</p>
]]></content:encoded>
	</item>
</channel>
</rss>

