Diary of a Mac Virgin

Basically the idea is to document my experience of getting used to a MacBook with OS X Tiger and familiarise myself with Blogger at the same time. That's right, I've never blogged before either.

Wednesday, November 08, 2006

Automator - First Steps

I've got some .pdf documents, about 300 of them actually, that were used to create a printed catalogue by some friends of mine. I'm helping them to create an online version of the catalogue and amongst other things, we need to extract the images.

The documents are not locked so Adobe Reader (I don't have Acrobat) would allow me to select an image and copy it to the clipboard. The easiest way to get them from there seemed to be by going into Preview and hitting Command-N to create a new file using the image data on the clipboard. I could then rename it and save it as a jpeg however I would then need resize it to make sure that it was no bigger than 300 x 400 pixels. Given that the files probably contain around 3000 pictures I figured that I needed a faster way of doing it.

The problem with something like this is deciding how long to spend researching the possible ways in which to tackle it before you just get stuck in and do the slog. In this instance I figured that it would end up taking a couple of weeks doing it by the above method. It seemed reasonable to me that I ought to be able to at least halve that by using more appropriate tools, in which case spending a couple of days researching is fairly easy to justify.

In fact it didn't take anything like that long to find an interesting looking piece of software called File Juicer which is able to extract images and other 'data types' out of larger files. Amongst other things, it can pull all the images out of a .pdf file is one go. Better still, the author provides instructions on how to use Automator to create a plug-in for Finder such that you can control-click the .pdf and have an option to extract files appear on the menu.

Now I'm not new to scripting and automating things but I'd not yet found time to investigate Automator, Applescript, or any of that stuff. Given that discovering File Juicer had gained me a couple of days I figured that now might be a good time to see what it could do about the rest of the process.

I didn't get very far with it, but then I didn't need to as I very quickly discovered two rather interesting things:

The first is that although Preview does not provide an option to resize images it does make an action available to Automator to 'scale' them.

The second is that you can attach actions to folder so that anything you drop into the folder gets processed by the action.

Thus by attaching the action described to a folder I how had the ability to drag and drop the output from File Juicer that I actually wanted (there are other images in the documents besides the product images that I need), into that folder.

Now of course 'scaling' isn't exactly what I wanted and as I'd noticed that Automator has the ability to import new actions, I decided to take a look what was already out there on the web. There is loads of stuff and it didn't take long for me to find an action called Save For Web which allows you to specify horizontal and vertical 'constraints' for the image i.e. it will resize the image if necessary so that it is no bigger than the stated width and height.

Half an hour of fiddling with automator and I had a system by which I could Control-Click on a .pdf and select the option to extract all the files to a new folder. Drag and drop the images that I want to a new folder, where they are automatically resized as needed and turned into jpegs. I can then rename them ready for upload.

It's not perfect but it took me about half a day and cost $12 for the full version of File Juicer (the trial version puts watermarks on some of the files). I could probably spend another day or two honing this to perfection but I figure that if we get stuck into using it as it is, we can have all the images processed before the week is out and take next week off.

0 Comments:

Post a Comment

<< Home