If I try to save a file to the root folder of a drive( Windows XP ) I get an error I don't understand. Is there something wrong with my code or system or is this a bug I didn't know about?
Code: Select allvar pngSaveOptions = new ExportOptionsSaveForWeb();
pngSaveOptions.format = SaveDocumentType.PNG;
pngSaveOptions.PNG8 = false;
app.activeDocument.exportDocument( new File( '/e/test.png' ), ExportType.SAVEFORWEB, pngSaveOptions );
What's wrong with this SFW
What's wrong with this SFW
I suppose you could call this a bug, it is a problem with Photoshop CS5 and CS6 that they won't let you write a file to the root directory. This is on Windows as can't test Macs. Previous versions of Photoshop are ok.
What's wrong with this SFW
Yes, I should have posted an update to this question. In the GUI you can save to a root folder. But you can't with either the DOM or Action Manager. At least on Windows with CS5. I also didn't test Mac.
So I just added a path check and an alert if needed before trying to save the file.
So I just added a path check and an alert if needed before trying to save the file.
What's wrong with this SFW
This seems to work on the root directory Mike...
Code: Select allfunction ftn1() {
function cTID(s) { return app.charIDToTypeID(s); };
function sTID(s) { return app.stringIDToTypeID(s); };
var desc6 = new ActionDescriptor();
var desc7 = new ActionDescriptor();
desc7.putEnumerated( cTID('PGIT'), cTID('PGIT'), cTID('PGIN') );
desc7.putEnumerated( cTID('PNGf'), cTID('PNGf'), cTID('PGAd') );
desc7.putInteger( cTID('Cmpr'), 9 );
desc6.putObject( cTID('As '), cTID('PNGF'), desc7 );
desc6.putPath( cTID('In '), new File( "G:/test.png" ) );
desc6.putInteger( cTID('DocI'), 1389 );
desc6.putEnumerated( sTID('saveStage'), sTID('saveStageType'), sTID('saveSucceeded') );
executeAction( cTID('save'), desc6, DialogModes.NO );
};
ftn1();
Code: Select allfunction ftn1() {
function cTID(s) { return app.charIDToTypeID(s); };
function sTID(s) { return app.stringIDToTypeID(s); };
var desc6 = new ActionDescriptor();
var desc7 = new ActionDescriptor();
desc7.putEnumerated( cTID('PGIT'), cTID('PGIT'), cTID('PGIN') );
desc7.putEnumerated( cTID('PNGf'), cTID('PNGf'), cTID('PGAd') );
desc7.putInteger( cTID('Cmpr'), 9 );
desc6.putObject( cTID('As '), cTID('PNGF'), desc7 );
desc6.putPath( cTID('In '), new File( "G:/test.png" ) );
desc6.putInteger( cTID('DocI'), 1389 );
desc6.putEnumerated( sTID('saveStage'), sTID('saveStageType'), sTID('saveSucceeded') );
executeAction( cTID('save'), desc6, DialogModes.NO );
};
ftn1();
What's wrong with this SFW
Sorry if I wasn't clear. I can't get SFW to save to a root folder. It looks like the code you posted was a normal save.
What's wrong with this SFW
Sorry Mike it was me not reading !
This is the best I could come up with...
Code: Select allvar f = new File("/g/test_png.png")
try{
var x = Folder(f.path).parent.name;
sfwPNG24(f);
}catch(e){
var f2= Folder(f.path + "/ZFolderTempZ");
if(!f2.exists) f2.create();
var f3 = new File(f2 +"/" +f.name);
sfwPNG24(f3);
f3.rename(f);
f2.remove();
}
function sfwPNG24(saveFile){
var pngOpts = new ExportOptionsSaveForWeb;
pngOpts.format = SaveDocumentType.PNG;
pngOpts.PNG8 = false;
pngOpts.transparency = true;
pngOpts.interlaced = false;
pngOpts.quality = 100;
activeDocument.exportDocument(new File(saveFile),ExportType.SAVEFORWEB,pngOpts);
}
This is the best I could come up with...
Code: Select allvar f = new File("/g/test_png.png")
try{
var x = Folder(f.path).parent.name;
sfwPNG24(f);
}catch(e){
var f2= Folder(f.path + "/ZFolderTempZ");
if(!f2.exists) f2.create();
var f3 = new File(f2 +"/" +f.name);
sfwPNG24(f3);
f3.rename(f);
f2.remove();
}
function sfwPNG24(saveFile){
var pngOpts = new ExportOptionsSaveForWeb;
pngOpts.format = SaveDocumentType.PNG;
pngOpts.PNG8 = false;
pngOpts.transparency = true;
pngOpts.interlaced = false;
pngOpts.quality = 100;
activeDocument.exportDocument(new File(saveFile),ExportType.SAVEFORWEB,pngOpts);
}