Monday, June 29, 2009

Automating DxO FilmPack (OSX)

DxO FilmPack is an awesome set of filters for your pictures, rendering them using classic films -- not just the colors, but the grain as well. It is available either as a standalone application or as a Photoshop plugin.

As an example of what FilmPack can do, here's one picture I took, first the original, then two filtered:


Fuji Superia 200:

Ilford Pan F Plus 50:

But even though it's really, really cool... it has a rather annoying limitation in its standalone version: you cannot apply a filter to a set of images, you have to apply it image by image. Of course, this might be all you need; but for my part, I would love selecting a type of filter I like and apply it on an entire set of pictures, as if I did shoot them using a film camera.

Hack it

Here is how you can do it, using a mixture of bash and AppleScript. Honestly, this is a hack -- it would be great for it to be integrated in FilmPack directly! but in the meantime, this can be useful...

As expected, the programmers did not bother to provide a scripting interface, so you seemingly cannot script it (it would have been useful for such a program with potential repetitive action, don't you think?).

Or can you ? It turns out that OSX has a rather nifty feature that allow near-global scripting: you can have access to all the GUI objects shown on screen, query their states, etc. It is not active by default -- you need to go (in the System Preferences) to "Universal Access" and click on "Enable access for assistive devices".

So, we starts with a bash script (we can call it ""):

for i in `ls *.JPG`;
do /Applications/DxO\ FilmPack\\ FilmPack\ 2 $i & osascript ./filmpack.script; done

This will, for each jpeg files in the current directory, open the binary executable of FilmPack and passing it the current jpeg as a parameter ($i). Doing this has for effect to start FilmPack and automatically load the image passed. Finally, as soon as FilmPack is started, we execute the filmpack.script.

This filmpack.script is a simple AppleScript:

tell application "System Events"
tell process "DxO FilmPack 2"
get enabled of menu item "Save As..." of menu 1 of menu bar item "File" of menu bar 1
set frontmost to true
click menu item "Save As..." of menu 1 of menu bar item "File" of menu bar 1
click button "Save" of sheet 1 of window "DxO FilmPack 2"
click menu item "Quit DxO FilmPack 2" of menu 1 of menu bar item "DxO FilmPack 2" of menu bar 1
end tell
end tell

This script asks the FilmPack application to save the current opened image, and to quit the application.

The only notable trick here is the "get enabled" line -- by asking AppleScript if the "Save As..." menu item is enabled, AppleScript will actually block until it can read the value, which makes the whole operation as fast as can be (no need for a sleep somewhere to wait until FilmPack is fully loaded and/or has applied the filter to the image).

Use it

Now, how to use it? well, let's say you have a directory Pictures containing your pictures. You can copy in that directory both and filmpack.script (or alternatively put those files in some default path). Then the last thing you have to do is to "configure" FilmPack once -- it will then remember the settings for the next time it is used. The easiest way to do this is thus to start FilmPack, open one of your picture, choose what kind of filtering you want to do, then save where you want all the pictures to be saved. Then quit FilmPack, and run!

1 comment:

Anonymous said...

It would be so nice if the would release the MAC update to V6. It took them like 2 months to get an update to 5.6 after OS X 10.6 came out.