Photoshop Scripting and Automation

The eyeOne of the nice features of many Adobe applications is the ability to automate repetitive or highly detailed sequences of tasks. The simple solution of using actions is more than enough for most purposes but sometimes you need more flexibility. That is where scripting can be useful. The obvious choice for running scripts within an Adobe application is ExtendScript or javascript. VBScript is also supported in Photoshop but it is probably not the best choice all around.

Simple External Automation

There is another option for using Photoshop functionality that I will be talking about here. If you are running Windows you can automate Photoshop and some other Adobe applications with OLE automation objects. This opens up possibilities for using Photoshop functionality within applications using general purpose programming languages such as C# or VB.Net. Ole Automation only makes sense if you have a need to combine Photoshop capabilities and other functionality that is not easily available within Photoshop. For instance, if you plan to use SQL Server or SQLlite along with image processing then building scripts that run entirely within Photoshop is probably not the best option. The application I describe is a standalone Windows desktop app built using Visual Studio 2015, VB.Net and SQLite.

Here is a small code snippet from my PSAuto class to give you a sense of how OLE automation might be done in VB.Net. The code uses Photoshop references that were added to the working project. These references must be added to allow Photoshop functionality to be accessed within Dot Net. This is just one possible approach that could be used for automation.

Imports Photoshop

    Public Structure pDocInfo
        Public _title As String
        Public _author As String
        Public _authPos As String
        Public _capt As String
        Public _captionWrtr As String
        Public _keywords As String
        Public _copyrighted As PsCopyrightedType
        Public _copyrightNotice As String
        Public _ownerURL As String
    End Structure

	Private Function doCreatPsApp() As Application
		If _psApp Is Nothing Then
			_psApp = New Application()
			_psApp.DisplayDialogs = PsDialogModes.psDisplayNoDialogs
		End If
		Return _psApp
	End Function

	Private Function doOpenPSDoc(ByVal path As String) As Document
		Dim psdoc As Document = Nothing

		Try
			Dim psapp As Application = doCreatPsApp()
			psdoc = psapp.Open(path)
		Catch ex As Exception
			Throw
		End Try

		Return psdoc
	End Function

    Public Function PopulateDocInfo(ByVal doc As Document, ByVal dinfo As pDocInfo) As Document
        doc.Info.Title = dinfo._title
        doc.Info.Author = dinfo._author
        doc.Info.AuthorPosition = dinfo._authPos
        doc.Info.Caption = dinfo._capt
        doc.Info.CaptionWriter = dinfo._captionWrtr
        doc.Info.Keywords = dinfo._keywords
        doc.Info.Copyrighted = dinfo._copyrighted
        doc.Info.CopyrightNotice = dinfo._copyrightNotice
        doc.Info.OwnerUrl = dinfo._ownerURL
        Return doc
    End Function
Building Calendars

Over the past few months I have been publishing calendar downloads on my blog with a new featured photograph every week. I release two versions of each calendar with North America or international week formatting. The difference being that one has weekdays starting on Sunday and the other Monday. Each calendar includes a 5×7 high resolution image at 300ppi in horizontal or vertical orientation. My approach to creating calendars is to use .psd files of static calendar content as templates. New images and text are then added and secure PDF documents are generated.

Here is the process for publishing the calendars and blog post images:

  • Select the featured image for the week
  • Add file and copyright information to the source image file
  • Export a version of the image having a horizontal dimension of 600 pixels or less for publishing online in the blog post
  • Create a 5×7 300ppi version of the image in horizontal or vertical format for the weekly calendars
  • Open Photoshop and load the appropriate North America and international calendar templates
  • Insert the photo into each template as a layer
    • Position the photo in the template
    • Edit image title text
    • Position the image title text relative to the image
  • Publish the completed calendars as secure PDF documents
  • Move finished documents to output folders
  • Write a blog post to discuss the image
Advantages of Automation

The steps outlined above are repetitive and tedious work. Just the kind of thing the computer should handle for a user. The entire workflow for creating PDF calendars and blog post images can be automated with a little work. The process can also easily be driven by information stored in a database using something like SQLite. The database can store everything including calendar templates, original source images, logo images, copyright information, titles, text data, calendar layout configurations, processing logs, etc. The user need only select a source image and enter some text fields. The application handles all aspects of document creation and information storage autonomously. The whole process takes a few seconds at most. Using a data driven approach also allows previous documents to be regenerated on demand.

My application is around 80% complete as of now. The prototype app can select and size images, add standard and image specific file/copyright information, load appropriate calendar templates, modify text content and add images as layers to the calendar templates. All information is stored in a local SQLite database. The app can use either an existing instance of Photoshop or start a new instance as necessary for processing.

Broader Uses for Scripting

My ultimate goal is to be able to automate any adobe application that supports scripting capability using ExtendScript or Javascript. That allows development of cross application and cross platform functionality. Depending upon the need there are also many possibilities for combining internal and external scripting. For instance Python comes to mind as a compliment to Javascript. Also combining scripting and actions seems interesting.

Of course application scripting is not something everyone will need or want to do. It is good to know the capability exists just in case you ever need it. For me it is a way to combine my passions for photography and code.

Architecture

Santo Tomas de Abiquiu - Abiquiu, New Mexico
Santo Tomas de Abiquiu – Abiquiu, New Mexico

By inclination I’m a regional photographer. Regional mostly implies within a few hundred miles for most of my photography with a few exceptions. I was born and raised in Utah and I have a strong attachment to the Four Corners States having lived in three and traveled in all.

By far the most naturally spiritual place I’ve ever encountered is Northern New Mexico. It is a land with civilizations going back at least a thousand years and probably far longer. The Spanish came to civilize the Puebloan peoples in 1598 and destroyed much of the rich culture that thrived there. Thankfully they didn’t succeed completely. They did leave behind a blend of cultures and religions including the beginnings of iconic New Mexico colonial architecture.

Part of the reason why Spanish architecture is so well adapted here is because it fits comfortably with traditional Puebloan building styles. The existing construction techniques practiced by native peoples were perfect for adobe churches and official buildings. A quick stroll around any town in New Mexico will make the point about how well New Mexican architecture has served the people for hundreds of years.

HDR How We See

The eyeSeveral years ago there was a lively debate going on about HDR still photography. At the core of the debate were people saying that HDR would never be ‘real’ photography because it was crude, garish and cartoon like. The back and forth was predictable and uninformative because no attention was given to two essential points. First, the raw cartoon appearance of HDR images was largely the result of inadequate software used in ways that were far from subtle. Second, HDR is about digital technology. More than a century of black and white and nearly a century of color still photography taught us to see images in very specific ways. HDR was well outside our normal understanding of what photographs look like.

It is important to remember that HDR is not a film photography technique. Sure you could bracket and scan several frames to get some sort of increased dynamic range out of film but that seems a ridiculous notion. Photographic film is a legacy medium that should be used to make the best possible chemical based analog images. It should not be used to imitate something else.

The imitation game also applies to digital technology. I happen to enjoy making black and white images using my digital camera. For years I’ve listened to people tell me that digital black and white could never be truly correct because it did not work by exposing light sensitive chemicals smeared on plastic film. Right, I can’t imitate analog silver, platinum or any other oxidized metal salt on paper. Nor do I wish to spend my time imitating analog photography. My goal is to make the best possible black and white images using the digital technology at my disposal. Sometimes that means using HDR to get the best possible images.

Photojournalism feels the pinch

So what happens when photojournalism, which huffs and puffs about standards and integrity, confronts standardized HDR image capture? More to the point, what happens when photojournalists find themselves producing images for display on HDR output technology? Well, then it’s time for a rethink of standards.

If you display images as facsimiles using ink on paper you are fine with the current standards. On the other hand, if your images are used on 4K televisions, you have to compete with 4K HDR video. HDR, unless captured using discreet data streams and created in post process, bakes a certain level of digital manipulation into the output. HDR output requires a reevaluation of what constitutes ‘clean’ source information. Not to mention that as imaging technology evolves so must the standards.

Legacy is fine but technology marches on

The still photography I practice will soon be as much a legacy activity as making images on film. My digital camera is essentially a video camera that is adapted to capture high quality single frames. Once you can get continuous high resolution capture, at whatever frame rate is appropriate, still cameras will be legacy technology. In addition, high resolution wide gamut output screens will pretty much mandate HDR content. It seems likely that HDR will be how we will see the world presented on our entertainment devices. Otherwise it will appear dull and lifeless to modern consumers.

Time to become a fine art photographer

If I want to stay involved with photography in the future as a non-professional then the audience for my work is likely to change. One-off hand crafted images may be thought of more as art in the future. There will always be a place for finely crafted works made by highly skilled individuals. Whether they are made with traditional artist materials, legacy photographic processes or some more modern technology makes little difference. Art is about communicating ideas. The practice of art may be closely tied to a particular medium but ideas are the free currency of creative expression. The opportunity for self expression is always present but the audience must value your work. Otherwise you must be satisfied to make work only for yourself.