Category Archives: Programming

Using Applescript to batch resize images

A couple of months ago, I wanted to try and collate a lot of my cloud accounts and reduce the number of services that I was using for various tasks. Part of it was to move my photos from Picasa to Dropbox which was a pretty daunting task given the number of photos I had and especially with the slow upload speeds we have in England.

It now isn’t uncommon to buy a smartphone with a 5, 8 or even 12 megapixel camera which leads to photos being several MB at the very least. Personally, I didn’t need my photos to stay in such a large resolution as I am not a professional photographer nor was I intending to have them blown up and printed. At most, my photos had to be at least 1080p which is enough to show friends and family on a computer or phone/tablet screen (I also didn’t want to wait several minutes for each photo to download if I was browsing them on the cloud).

After a quick resizing test, reducing the resolution to 1080p brought the file size down to about 0.5MB on average which was a huge improvement and started to look for software to do a batch resize.

Only problem was that I couldn’t find anything for the Mac that would be able to handle directories of photos in different orientations and skip photos that were already smaller then 1080p. A few results pointed me in the direction of using AppleScript and although I hadn’t scripted in it before, I thought I give it a try given how powerful it is for automation.

Personally, I wasn’t a big fan of the syntax and found my muscle memory for operators kept going to usual keys used in most languages which was a little frustrating. e.g logical OR is the word ‘or’ instead of ‘||’. However, I had no problem creating a script quickly to mass resize photos and most questions were a Google search away. The only issue I had was the script timing out and after a little bit of debugging, I found out this was only happening on large folders and I had to override the default timeout value.

Below is a link to the script and as usual, it is supplied as is with no guarantee. I recommend trying a sample copy of photos to see if it would suit your needs. 

Tagged , , ,

Working with Twitter API 1.1 with Unity

Update 9th Oct 2014: Let’s Tweet in Unity has been updated to work with API 1.1:!/content/536

Back around late summer/early autumn, I was working on a project that involved showing Tweets in a unique way using Unity. The concept itself was not complicated and with Unity being Unity, we thought there would be a plugin or existing code to work with Twitter’s API and we could prototype the concept relatively quickly.

We were wrong. It took us a few days between us to get the search query working with Unity using Twitter API 1.1.

There are quite a few resources and plugins for Twitter’s old API (1.0) but none for 1.1. 1.0 was a really simple interface in terms of producing a URL query and the result would be a JSON string. 1.1 added the need to use OAuth authentication which has caused problems for many developers judging from the various forums littered with queries.

At this stage we had two problems, getting the OAuth Authentication correct and working with Unity’s WWW class for web queries instead of the .NET framework.

Continue reading

Tagged , , , ,

Accessing the Yelp API with OAuth within Unity

I’m working on a side project at home which involved accessing the Yelp API with Unity which required the use of OAuth authentication and as the GitHub examples didn’t have any C# variations, I put one together myself with some help from Google.

The Yelp API is pretty straight forward despite the large number of parameters involved and the OAuth signature generation is handled by the outh project on I found. As it only consists of a single source file, it makes it really simple to integrate in a project and use.

I had to make several changes to it as HttpUtility isn’t accessible in Unity and therefore I replaced all instances of HttpUtility.UrlEncode with WWW.EscapeURL which is part of Unity’s libraries and also added a bug fix that was purposed from the issues list from the project which can be found here.

A sample of the API call can be found after the jump.

Continue reading

Tagged , , , ,