How To Run a Photoshop From C#‎‎‎‎‎

Here's our goal:

  1. Open an image in Photoshop
  2. Run an action to filter the image
  3. Save the new image somewhere new
  4. Close the image

Step 1) Install Photoshop & Visual Studio

Really, if you clicked on an article called "Automating Photoshop With C#‎‎‎‎‎" then you've probably got step 1 done. The only real bit of information here is that I don't know of any way to do Photoshop automation without it installed.
So if you need to run the automation on a different computer (like a server), then you'll have to install Photoshop
Step 2) Cut a Hole...

Wait, wrong algorithm.
Step 2) Reference the Photoshop Assemblies

Bust open your Visual Studio solution, right-click your project, and choose "Add Reference...".
Choose the COM tab, then choose the following & click "OK".
Adobe Photoshop CS5 Object Library
Adobe Photoshop CS5 Type Library
You might have CS3 or CS4 if you're behind the times. You may also have a braided belt.
Step 3) Copy & Paste My Code

public static void RunAction(string orig, string target, string action, string group)


    ApplicationClass app = new ApplicationClass();
var doc = app.Open(orig);
app.DoAction(action, group);
var options = new BMPSaveOptions();
doc.SaveAs(target, options, true, PsExtensionType.psLowercase);
doc.Close(PsSaveOptions.psDoNotSaveChanges);




Step 4) Execute the Code

Here's how I run the code:



  • @"C:\Projects\TestPhotoshop\TestPhotoshop\bin\Debu g\original.bmp",
  • @"C:\Projects\TestPhotoshop\TestPhotoshop\bin\Debu g\new.bmp",
  • "Sepia",
  • "Default");