<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="https://shkspr.mobi/blog/wp-content/themes/edent-wordpress-theme/rss-style.xsl" type="text/xsl"?>
<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>I Love Open Source &#8211; Terence Eden’s Blog</title>
	<atom:link href="https://shkspr.mobi/blog/2010/02/i-love-open-source/feed/" rel="self" type="application/rss+xml" />
	<link>https://shkspr.mobi/blog</link>
	<description>Regular nonsense about tech and its effects 🙃</description>
	<lastBuildDate>Fri, 06 Oct 2023 08:58:17 +0000</lastBuildDate>
	<language>en-GB</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0</generator>

<image>
	<url>https://shkspr.mobi/blog/wp-content/uploads/2023/07/cropped-avatar-32x32.jpeg</url>
	<title>I Love Open Source &#8211; Terence Eden’s Blog</title>
	<link>https://shkspr.mobi/blog</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title><![CDATA[I Love Open Source]]></title>
		<link>https://shkspr.mobi/blog/2010/02/i-love-open-source/</link>
					<comments>https://shkspr.mobi/blog/2010/02/i-love-open-source/#respond</comments>
				<dc:creator><![CDATA[@edent]]></dc:creator>
		<pubDate>Fri, 26 Feb 2010 22:21:40 +0000</pubDate>
				<category><![CDATA[voteuk]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[Open Source]]></category>
		<guid isPermaLink="false">http://shkspr.mobi/blog/?p=1758</guid>

					<description><![CDATA[As I mentioned in my last post about VoteUK, I found the TheyWorkForYou API to be a little lacking when it came to image sizing.  I posted a request asking if there was a pattern to the image sizes and, if not, was it possible to have the sizes returned in the API.  The &#34;standard&#34; open source reply - &#34;fix it yerself&#34; - was predictably swift.  So I did.  The source code is remarkably accessible -…]]></description>
										<content:encoded><![CDATA[<p>As I mentioned in <a href="https://shkspr.mobi/blog/2010/02/voteuk-updates/">my last post about VoteUK</a>, I found the TheyWorkForYou API to be a little lacking when it came to image sizing.</p>

<p>I <a href="https://groups.google.com/a/mysociety.org/g/mysociety-community/c/7JZo-nCZis0/m/NUQM5GCHjLAJ">posted a request</a> asking if there was a pattern to the image sizes and, if not, was it possible to have the sizes returned in the API.</p>

<p>The "standard" open source reply - "<em>fix it yerself</em>" - was <a href="https://groups.google.com/a/mysociety.org/g/mysociety-community/c/7JZo-nCZis0/m/qTDLZCaSRAcJ">predictably swift</a>.</p>

<p>So I did.</p>

<p>The <a href="http://github.com/mysociety/theyworkforyou">source code</a> is remarkably accessible - although a few more comments wouldn't go amiss.&nbsp; This was my first experience with GIT and Github.&nbsp; It was easy to get the code and, luckily, I didn't have to dive too far in to its syntax.</p>

<p>I had initially thought about using the EXIF data within the images to get the width and height.&nbsp; Unfortunately, not every image can be guaranteed to have (accurate) EXIF data.&nbsp; PHP to the rescue once again with the <a href="http://php.net/manual/en/function.getimagesize.php">getimagesize() </a>function.</p>

<p>So, where we previously had</p>

<pre>if ($image) $row['image'] = $image;</pre>

<p>This becomes</p>

<pre>if ($image) {
    list($width, $height) = getimagesize($image);
    $row['image'] = $image;
    $row['image_height'] = $height;
    $row['image_width'] = $width;
}</pre>

<p>Many thanks to Matthew Somerville for <a href="https://groups.google.com/a/mysociety.org/g/mysociety-community/c/y3_fmrVWk80/m/hUaNUpmZ8d0Jl">testing and releasing the patch in double quick time</a>. You can <a href="http://github.com/mysociety/theyworkforyou/commit/b6d93223b1d29dc1cc3bbe00abc61307ed89e0af">examine the changes</a> made to the code.</p>

<p>So now the API returns,</p>

<pre><img>/images/mps/10409.jpg
<image_height>59</image_height>
<image_width>49</image_width></pre>

<p>Brilliant!</p>

<p>So, I have a problem, I can see how much effort it will be to fix, I suggest a solution, it works and goes into production.&nbsp; That's the awesome power of open source.</p>
<img src="https://shkspr.mobi/blog/wp-content/themes/edent-wordpress-theme/info/okgo.php?ID=1758&HTTP_REFERER=RSS" alt="" width="1" height="1" loading="eager">]]></content:encoded>
					
					<wfw:commentRss>https://shkspr.mobi/blog/2010/02/i-love-open-source/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
