Moonshine2: The art of Scripting to make your own Distillery

Moonshine: This name is a slight play on the theme of "the distiller" — arguably the engine of Acrobat since version 1.0. The piece of magic that converts reverse-polish-notation, stack-based Postscript to PDF — Moonshine just seemed like a logical extension of the name.

Learning JavaScript has been a "back-burner" project of mine in recent years. Updating my "Moonshine" scripts for Photoshop was a perfect first project.

Support for PDF across Adobe applications is extensive. Saving out of Illustrator, InDesign through to rendering PDF into bitmaps in Photoshop: PDF is a well-supported exchange format between Adobe applications.

Rather than using Actions, which are step-by-step automation of serial processes, scripts provide a deeper level of control and conditionality; branching if a condition occurs. New in Photoshop CS is the ability to create user-interface elements to further customize the executed actions.

Additionally, scripting Adobe applications has changed in recent versions. Acrobat’s JavaScript support is extensive and well documented. After InDesign 1.0, Illustrator 9 and Photoshop 7 increased platform scripting support (Visual Basic/VBScript on Windows and AppleScript on MacOS) — in the CS versions a cross-platform JavaScript engine is available. There is even a full JavaScript debugger in Photoshop. Doesn’t quite compare to the elegance of the Healing Brush or History Brush — but for scripters, it’s a godsend. No more faith-based programming.

Originally written as a proof-of-concept for an Advertising agency in Australia, this script was designed to use the PDF rendering engine of Photoshop to generate JPEGs for web-site publication and client review. Rather than re-generate smaller PDFs, the original Moonshine asked Photoshop to open the PDFs, and render a JPEG from the first page. Moonshine2 updates this to work with Photoshop CS’s JavaScript engine.

Installing the Script:

Using the JavaScript scripting engine in Photoshop, this script opens PDFs from a directory and saves them as JPEG.

The file has two contents:


Install this file into the folder "Scripts" inside the "Presets" wherever Photoshop CS is installed on your Mac or PC.

After restarting Photoshop, this script will appear under the "File > Scripts…" menu. Keyboard shortcuts (Edit > Keyboard Shortcuts) can be assigned to scripts, integrating them into the Photoshop application.

MoonshineStart.vbs: (optional)

This script can "live" anywhere on your PC; its function is to launch the script from the Windows shell environment. Please note the line underneath the text in all-caps: you may need to set the path to the script accurately.

Launching and Using Moonshine2

Select Moonshine2 from the File > Scripts menu.

src=’’ width=’372′ height=’228′
alt=’This is alt text’>

The first dialog asks for the source folder/directory. This is where the "watched" folders reside.

src=’’ width=’326′ height=’320′
alt=’This is alt text’>

Watched Folders, sometimes known as Hot Folders, is a feature added to Distiller in version 3 and only found in the Professional versions of Acrobat 6 and 7. By monitoring a particular folder, the Distiller starts the PDF generation process once a Postscript file or Encapsulated Postscript File is dropped into the "in". Once processed, the completed PDF (and the processed Postscript file) is placed into an "out" folder. For more information, read "Watching Folders" in Applying Custom Distiller Settings

The second dialog asks questions as to the:

src=’’ width=’306′ height=’210′
alt=’This is alt text’>

  • dots-per-inch (DPI) of the JPEGs Moonshine2 will create. For web-based images, a resolution of 72 DPI (the default) is OK.
  • width of JPEGs: the width in pixels is the scale the PDFs will be rasterized to when opened by Moonshine2. PDF, as a scalable format, can be small or as large as you need.
  • quality of the saved JPEG: this slider permits the selection of the saved JPEG. The higher the number, the greater the file size and the quality.
  • Once these values are chosen, Moonshine2 looks in the "In" folder for PDFs
  • Opens them at the width and resolution as requested
  • Saves the resulting JPEGs, with the same file name but different file extension, into the :"Out" folder
  • Moves the PDF into the "done" folder

When launched from the MoonshineStart.vbs script, the path is set depending on where the script is installed on your computer. Default values are passed into the Moonshine2.js from variables as defined at the top of the VBscript file.

You May Also Like

About the Author: Nick Hodge

Leave a Reply