Inspired by a recent episode of The Mac Cast I decided to see if I could come up with a simple way of getting a word count of a PDF on OS X using only tools that come standard with the OS.

Because of OS X’s Unix underpinnings, all Macs have access to the Unix wc command which calculates word counts on given input. OS X also has a handy built in Terminal command to access the contents of the clipboard (pbpaste). This leads to an obvious simple manual solution:

  1. Open the PDF in Preview
  2. Select All Text
  3. Copy to clipboard
  4. Run the Terminal command: pbpaste | wc -w

This is a bit cumbersome though, so I went on to create a simple OS X Service to calculate the word count of any selectable text in any app (the fact that this is even possible, let alone easy, is why I love OS X).

For those of you just looking for a copy of the Service, you can download it here:

Download

To install the service simply extract the automator file from the ZIP archive and copy it into either the Library/Services folder in your home directory, or the system-wide service folder /Library/Services.

Once the Service is installed you can use it in almost any OS X app (specifically in any app written using the standard Cocoa libraries) by selecting some text, right-clicking on it, and selecting the Word Count service:

Right Click Selected Text to Invoke the Service

When done the results will look something like this:

Sample Output

Those of you who want to see how easy this Service was to write, read on and I’ll walk you through it.

Read more

Tagged with:

Back in 2011 I wrote a blog post explaining how to create an OS X Service for stripping keywords from image files. In this post we’ll use the same technique to create a Service for stripping geotags from JPEG images.

As with the keyword stripping service, there are two prerequisites for this action, one is required, one is optional. You absolutely MUST have install EXIFTool installed, and it would be good if you also had Growl installed, but it’s not essential.

Read more

Tagged with:

Yesterday I posted my thoughts on watermarking images for uploading to the web. This post formed the basis of myself and Allison Sheridan’s discussions in the Chit Chat Across the Pond segment on tonight’s Nosillacast Mac Podcast. During the discussion we talked a little about how I watermark my images, and I realised that I hadn’t released a version of my image processing scripts since 2008! I promised I’d remedy that, so today, after a little tidying up, I’m releasing the current snapshot of my scripts under the FreeBSD license.

I’m not releasing these scripts as a polished software package that’s ready to use, but rather, as a starting point for anyone who wants to create their own watermarking scripts. If you’re not prepared to get stuck into the command line and a little Perl (VERY little is needed mind), these scripts are of no use to you!

The scripts rely on the free and open source ImageMagick command line image editing tools, so you’ll need to install ImageMagick before you get stuck in. If you’re running OS X, I’d recommend installing ImageMagick via the free and open source MacPorts package manager.

Read more

Tagged with:

Update – 13 April 2012: Apple have released another update to Java (via software update) which automatically disables Java in Safari, and removes Flashback if it has infected your system. Please use Apple’s update rather than relying on this script!

Update – 10 April 2012: I have edited the script to run the additional commands recommended by TidBITS. The Download button will now return version 0.2 of the script.

It’s finally happened, there has been a serious malware outbreak on the Mac. Over half a million Macs have been infected with the latest variants of the Flashback malware. Earlier versions of this malware relied on tricking users into running an installer, or approving a request for permission to execute, but that has all changed now. The malware moved from being a simple trojan that relied on tricking people into running it, to a fully automated attack requiring no user interaction. The reason for this transformation is that the malware started to use flaws in Java, first, old vulnerabilities that were patched ages ago, so only affecting people who don’t keep their computers up to date, but this week, attacking flaws that Apple had, at the time, not yet patched. This means that for a few days, even the most diligent Mac users could have been hit.

This infection has no noticeable symptoms, and did not require you do do anything “stupid” to get infected. Any Mac user, not matter how careful, could have been infected. So, you need to check to be sure you are not one of the half million plus victims! Read more

Tagged with:

Following on from my post yesterday with three examples of using Automator to create Services, and some good suggestions in the comments, I spent some time this afternoon making the script in the third of those examples a little more efficient, and a lot more robust.

The Service I optimised was the one to strip keywords from image files. This Service assumes that both Growl and EXIFTool are installed, and that you’re running OS X 10.6 Snow Leopard or later.

Read more

Tagged with:

Since I first started using OS X at version 10.3 I’ve always felt that the services menu had great potential but badly needed some fit and polish to make it actually live up to that promise. It has been so bad that it is basically forgotten, and almost no one remebers that it even exists. In every application in OS X there is a menu item under the apps’s main menu (the one in bold with the same name as the app) called Services, that’s what I’m talking about. When it comes to the services menu both Tiger and Leopard were major disappointments because they didn’t bring any real improvement to the neglected services menu. SnowLeopard on the other hand is a totally different story. Similarly, when Automator first came out I thought it had great promise, but that it was a very 1.0 kind of offering, again, in need of some fit and polish to allow it live up to its obvious potential. SnowLeopard provides a lot of that fit and polish, and really brings Automator forward significantly. And what’s better, Apple have combined the fit and finish in these two apparently unrelated products together, to provide some exceptionally powerful functionality.

Read more

Tagged with:

Update (18 June 2012) – A more up-to-date version of these scripts can now be found here.

My Myers Briggs personality profile insists that I “prefer economy of effort”, you can probably translate that to “is a lazy sod”. Because of this I like automating repetitive tasks. It all started when I wanted a quick and easy way to prepare my images for posting to my website. I wanted them resized with my URL and the Creative Commons icon added in, and I wanted to be able to process a whole directory of images in one go. I started by playing around with the GD libs in PHP, but soon realised it would be quicker and easier to use Perl to shell out to the command line tools from Image Magick. At the time I wrote a post on my choice to do this which also contained the initial code. That code has been expanded and evolved since, and now includes functions for rendering nice (in my opinion) borders and titles on my better images. If you want to see examples checkout the Photo of the Week category on this blog..

[tags]Perl, Image Magick, script, programming, image processing[/tags]

Read more

Tagged with: