Search code examples
photoshopphotoshop-script

Photoshop script suddenly stopped working - Error 8000


So I made a script for Photoshop based on this generator

The important part is

#target photoshop

function main() {
    //  prompt user to select source file, cancel returns null
    var sourceFile = File.openDialog("Select a 1:1 sqaure PNG file that is at least 618x618.", "*.png", false);
    if (sourceFile == null)  { 
        // user canceled
        return;
    }

    var doc = open(sourceFile, OpenDocumentType.PNG);
    if (doc == null) {
        alert("Oh shit!\nSomething is wrong with the file. Make sure it is a valid PNG file.");
        return;
    }

....
}

main();

this allways worked. But when today I wanted to change something in the script (I haven't even started yet and not used it for about 2 weeks) I suddendly only get an error (translated from german):

Error 8000: The file can not be opened since the parameters for opening are incorrect.
Line:764
-> doc = open(sourceFile, OpenDocumentType.PNG);

How can I open a PNG file via a File.Open dialog in a Photoshop script?


I already tried to add the app

var doc = app.open(sourceFile, OpenDocumentType.PNG);

to remove the document type specifier

var doc = open(sourceFile);

or to add this as I saw it in many forums

var doc = open(sourceFile, OpenDocumentType.PNG, undefined);

and variations between them. Nothing helped so far.


For debugging I also added

alert(sourceFile);

before the according line and get e.g.

~/Desktop/Example/originalImage_2000x2000.png


Solution

  • The problem apparently was with Photshop in general! When I opened Photshop I didn't even get the default view of last opened files etc and actually was not able to open any file ... but never tested this first.

    After rebooting the PC and launching Photshop now everything went back to normal and the script just runs fine and as expected.