Skip to main content
Inspiring
July 28, 2022
Answered

Using photoshopFileOptions ?!?

  • July 28, 2022
  • 1 reply
  • 599 views

I have a PSD file, containing layers, that I want to open in Illustrator.

 

To open PSD files, the Illustrator Scripting Guide suggests using the following construct
--------------------------------------------------------------------------------------------
// Opens a Photoshop file containing layers with
// preferences set to preserve layers

var psdOptions = preferences.photoshopFileOptions;
psdOptions.preserveLayers = true;
psdOptions.pixelAspectRatioCorrection = false;

// open a file using these prefs
var fileRef = File(psdFilePath);
if (fileRef != null) {
var docRef = open(fileRef, DocumentColorSpace.RGB);
}
------------------------------------------------------------------------------------------------------

and the Application.open() method is described as follows app.open(file[, documentColorSpace][, options])


i am trying to open psd files, not using a variable "fileRef".
--------------------------------------------------------------------------------------------------------
var fileRef = File(psdFilePath);
if (fileRef != null) {
var docRef = open(fileRef, DocumentColorSpace.RGB);
}
----------------------------------------------------------------------------------------------


In both cases, using or not using  "var psdOptions", when opening a PSD file, the application shows a window "Photoshop Import Option".

Moreover, when using the notation
--------------------------------------------------------------------
var docRef = app.open(fileRef, DocumentColorSpace.RGB, psdOptions);
--------------------------------------------------------------------
Where I explicitly specify the options for opening a document, I get the following response:

 

Exception has occurred: 9007
unknown open options found.

 

Is this a bug, or am I not understanding something?

This topic has been closed for replies.
Correct answer femkeblanco

Use the first way.  Add this before the open() function:

 

app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;

 

 

1 reply

femkeblanco
femkeblancoCorrect answer
Legend
July 28, 2022

Use the first way.  Add this before the open() function:

 

app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;

 

 

AnyONAuthor
Inspiring
July 28, 2022

Yes, this method works... But it also works without var psdOptions declaration...

Disposition_Dev
Legend
July 28, 2022

yea, if you're gonna disable the part of the script that tells you when something's wrong, you've gotta do your own checks to make sure everything goes right. Otherwise it's gonna go wrong and you're not gonna know till later.

 

Just add some validation logic before the app.open() call to ensure that all the arguments you're passing in are valid.