SaveOptions.DONOTSAVECHANGES doesn't work sometimes
Hi, there is a part of my script which saves automatically color/black and white version of the file, then resized it to social media size and then adds aolumns for a square for Instagram. It ends by command
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
but sometimes the document stays opened and I have to press ctrl-w to closing it and agree closing without saving. Any idea how to prevent this?
Thnaks
{
/// ... a some layer operations are here....
turnBWLayer(true);
SaveJPG(filePath + "/big", fileName + ".jpg");
ResizeLonger(2044);
SaveJPG(filePath + "/small", fileName + "c.jpg");
turnBWLayer(true);
SaveJPG(filePath + "/small", fileName + ".jpg");
Unlock(filePath);
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
}
function turnBWLayer(onoff) {
if (app.activeDocument.layers.length > 0)
{
for (var i = 0; i < app.activeDocument.layers.length; i++) {
var currentLayer = app.activeDocument.layers[i];
if (currentLayer.name == "BW") {
currentLayer.visible = onoff;
return true;
}
}
}
return false;
}
// this is because another script detects an operation in progress and waits for finishing
function Lock(folder) {
var _lock = new File(folder + "/lock.txt");
_lock.open("w");
_lock.writeln(".");
_lock.close();
}
function Unlock(folder) {
var _lock = new File(folder + "/lock.txt");
_lock.remove();
}
function SaveJPG(folder, fileName)
{
jpgFile = new File(folder + "/" + fileName);
jpgSaveOptions = new JPEGSaveOptions();
jpgSaveOptions.embedColorProfile = true;
jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
jpgSaveOptions.matte = MatteType.NONE;
jpgSaveOptions.quality = 12;
app.activeDocument.saveAs(jpgFile, jpgSaveOptions, true,Extension.LOWERCASE);
}
