Skip to main content
Participant
June 14, 2006
Question

vb.net (or c#) to photoshop batch

  • June 14, 2006
  • 2 replies
  • 2203 views
Trying to automate Photoshop from .Net application. Works fine with documents, layers, but getting error on batch method:

Dim appRef As Photoshop.Application
appRef = New ApplicationClass
Dim batchOpt As New BatchOptions
batchOpt.Destination = PsBatchDestinationType.psFolder
batchOpt.DestinationFolder = "c:\0\1\"
batchOpt.OverrideOpen = True
batchOpt.OverrideSave = True
batchOpt.SuppressOpen = True
batchOpt.ErrorFile = "c:\mylog.txt"
Dim flNaming(0) As PsFileNamingType
flNaming(0) = PsFileNamingType.psDocumentNameMixed
batchOpt.FileNaming = flNaming
Dim inputFiles(0) As String
inputFiles(0) = "c:\0\myImage.jpg"
appRef.Batch(inputFiles, "AutoLevelsContrast", "Default Actions", batchOpt)

Here "AutoLevelsContrast" is my action.
On batch operation getting exception:
"Illegal argument - argument 1. -Unsupported Variant type"
This topic has been closed for replies.

2 replies

Participant
September 22, 2021
Type PhotoshopType = Type.GetTypeFromProgID("Photoshop.Application");
            Type PhotoshopBatchOptType = Type.GetTypeFromProgID("Photoshop.BatchOptions");
            dynamic appRef2 = Activator.CreateInstance(PhotoshopType);
            dynamic batchOptions = Activator.CreateInstance(PhotoshopBatchOptType);

            object[] obj = new object[1];
            obj[0] = @"D:\youtimage.tif";

            batchOptions.overrideSave = true;
            batchOptions.overrideOpen = true;
            batchOptions.destination = PsBatchDestinationType.psSaveAndClose;
            appRef2.Batch(obj, ActionSet, ActionName, batchOptions); 

 

The array of images needs to be a true object[] a string array will not work.

Participant
February 15, 2008
Could you please post how did you create the Photoshop object throgh .NET? What dll's will be required? I am searching for a week but no luck so far. I saw your post where you are working with photoshop document and layers. Is it possible to manipulate the text layer?

Your help would be appreciated.

Thanks
Participating Frequently
February 15, 2008
> What dll's will be required?

What version of Photoshop do you have installed?

Aandi Inston
Participant
September 22, 2021

I'm trying this with 13.0 with CS6 and can't figure out how to create a AliasArray object.