<?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>biotext.org.uk &#187; graphics</title>
	<atom:link href="http://biotext.org.uk/tag/graphics/feed/" rel="self" type="application/rss+xml" />
	<link>http://biotext.org.uk</link>
	<description>Not a typewriter</description>
	<lastBuildDate>Sat, 05 Feb 2011 14:18:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Finding the dimensions of a PostScript image</title>
		<link>http://biotext.org.uk/finding-the-dimensions-of-a-postscript-image/</link>
		<comments>http://biotext.org.uk/finding-the-dimensions-of-a-postscript-image/#comments</comments>
		<pubDate>Tue, 08 Sep 2009 16:35:22 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[graphics]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[publishing]]></category>

		<guid isPermaLink="false">http://biotext.org.uk/?p=387</guid>
		<description><![CDATA[If I have images in .ps or .eps format, how can I tell how big they are? i.e. how big would they print out at &#8216;natural&#8217; size without any scaling? If they have a correct bounding box defined &#8212; more likely with EPS than PS files &#8212; this bit of Perl will show you the [...]]]></description>
			<content:encoded><![CDATA[<p>If I have images in .ps or .eps format, how can I tell how big they are? i.e. how big would they print out at &#8216;natural&#8217; size without any scaling?</p>
<p>If they have a correct bounding box defined &#8212; more likely with EPS than PS files &#8212; this bit of Perl will show you the width and height in cm:</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/env perl</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">use</span> strict<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> warnings<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Usage: measure.pl &lt;postscript-file&gt;</span>
<span style="color: #666666; font-style: italic;"># Or send it some data on stdin.</span>
<span style="color: #666666; font-style: italic;"># Assuming the BBox is correct, it'll tell you the </span>
<span style="color: #666666; font-style: italic;"># dimensions in cm.</span>
&nbsp;
<span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span> <span style="color: #000066;">defined</span> <span style="color: #009900;">&#40;</span> <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$line</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&amp;lt</span><span style="color: #339933;">;</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">$line</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">/^%%BoundingBox:\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/</span> <span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">my</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">$llx</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$lly</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$urx</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$ury</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">$1</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$2</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$3</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$4</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$x_pts</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$urx</span> <span style="color: #339933;">-</span> <span style="color: #0000ff;">$llx</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$y_pts</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$ury</span> <span style="color: #339933;">-</span> <span style="color: #0000ff;">$lly</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$x_in</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$x_pts</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">72</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$y_in</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$y_pts</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">72</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$x_cm</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$x_in</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">2.54</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$y_cm</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$y_in</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">2.54</span><span style="color: #339933;">;</span>
        <span style="color: #000066;">printf</span> <span style="color: #ff0000;">&quot;%.1f %.1f<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$x_cm</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$y_cm</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">last</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Dead handy when preparing images for a paper.</p>
<p>PS if you are hazy about the difference between PS and EPS &#8212; like me &#8212; have a look at <a href="http://www.tailrecursive.org/postscript/eps.html">this article</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://biotext.org.uk/finding-the-dimensions-of-a-postscript-image/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

