Question

I've written a function to determine whether an image file has been saved or not. It relies on a try / catch for the path name.

hasImageBeenSaved()

function hasImageBeenSaved()
{
    var n = app.activeDocument.name;
    try
    {
        var myPath = app.activeDocument.path;
        alert(myPath);
        return true;
    }
    catch(e)
    {
        alert(n + " has not been saved");
        return false;
    }
}

Scripting in Photoshop normally entails working with saved images or images that will get saved after being altered. Functionally the above is fine; but I'm sure there's a more elegant solution. Any ideas?

Était-ce utile?

La solution

I found out a one liner

alert( app.activeDocument.saved);

However, under further investigation it doesn't take into account a newly created document.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top