Copy link to clipboard
Copied
Hi I'm relatively new to scripting for Photoshop and have stumbled across an issue I can't seem to find an answer for. The script I'm writing saves out specific layers and names them accordingly based on the PSD's name (Diffuse, Spec, Normal, etc.). The script works perfectly fine when I save out in a TIFF format but when I try to save out SGIRGB, Photoshop always presents a SaveAs dialog, which I want to avoid.
Is anyone aware of away to have my the SGIRGBSaveOptions() skip the Save As dialog?
Also my company uses RGB format which is why I cannot just use TIFFs.
Copy link to clipboard
Copied
Did you install the optional SGIRBG Pligin and code the SaveAs options correctly? I have never opened or saved an *.SGI file.
Optional Photoshop CC plug-ins
Copy link to clipboard
Copied
Hey yakzsmelk, would you mind sharing your code? At least the part where you're saving to this format. That might give us a better idea of where the issue could be.
Copy link to clipboard
Copied
Hey guys thanks for the responses!
@JJMack: Yes I do have the plugins installed
@Javier: Sure the code is below, I cut a few things out to remove anything that might be considered work sensitive so if a piece doesn't make sense that's probably why.
Again if the save settings are switched to TIFF it works correctly.
#target photoshop
var AD = activeDocument;
var docPath = AD.path;
var docName = AD.name;
var savePath = new Folder (docPath.parent);
var saveName = docName.substring(0 , docName.length - 4);
//Layers that should be saved out
var layerNight = AD.artLayers.getByName("NIGHT");
var layerColor = AD.artLayers.getByName("COLOR");
//This is the savepath and name the file will be saved under
nightFile = new File(savePath + "/" + saveName + "_night.rgb")
colorFile = new File(savePath + "/" + saveName + "\.rgb")
//Find the document's height for resizing
var docHeight = AD.height;
var docWidth = AD.width;
var savedState = AD.activeHistoryState;
//FILE OPTIONS
//SGIRGB Save Options
saveOptions = new SGIRGBSaveOptions()
saveOptions.spotColors = false
saveOptions.alphaChannels = true
saveOptions.typename = false
saveNight ()
saveColor ()
//Function for saving the Night Data
function saveNight (){
//Toggles required layer on and other off to make sure NIGHT is top layer
layerNight.visible = true
layerColor.visible = false
resizeDocument()
saveOptions.alphaChannels = false
app.activeDocument.saveAs(nightFile, saveOptions, true,Extension.LOWERCASE)
revertHistory ()
}
//Function for saving the Color Data
function saveColor (){
//Toggles required layer on and other off to make sure COLOR is top layer
layerNight.visible = false
layerColor.visible = true
saveOptions.alphaChannels = false
app.activeDocument.saveAs(colorFile, saveOptions, true,Extension.LOWERCASE)
}
function resizeDocument(){
//app.activeDocument.suspendHistory ("History Revert", "saveColor()")
app.activeDocument.resizeImage((docWidth/2), (docHeight/2), null, ResampleMethod.NEARESTNEIGHBOR)
}
function revertHistory (){
//'AD.historyState.getByName ("History Revert");
AD.activeHistoryState = savedState;
app.purge (PurgeTarget.HISTORYCACHES);
}
Copy link to clipboard
Copied
I thought saveoption.typename was read only you seem to set that to false? I would also think that the file extension would be something like .sgi not .rgb but then I have not installed the plug-in so I do not know the list of possible file extensions.
I just installed the Plug-IN I see .sgi is the default that .rgb is also valid and if you have both an Alpha Channel and a Spot Color channel you can only save and SGI file with an Alpha channel the Spot cant option is grayed out. If I delete the Alpha channel I still can not save an SGI with the spot color channel the alpha channel and spot color option are grayed out. If I have both a Alpha channel and spot channel I can saved a Layered PSD and a Layered TIF with both channels.
When I used the script you posted both .rgb file were saved no save as dialog opened. The night rgb file was smaller then the color rgb file neither had Alpha channels when I opened them. The save as changed your .rgb to .sgi. When I used save as to save a a .SGI when I opened that sgi file it had two alpha channels.
Copy link to clipboard
Copied
JJMack thank you again for checking this out!!
When I used the script you posted both .rgb file were saved no save as dialog opened.
This confuses me. Every time I run the script it opens the Save As Dialog.
The night rgb file was smaller then the color rgb file neither had Alpha channels when I opened them.
This is correct.
The save as changed your .rgb to .sgi. When I used save as to save a a .SGI when I opened that sgi file it had two alpha channels.
I don't know what would cause that.
A few things I noticed;
In your samples, the PSD isn't saved yet. If I run the script with an unsaved PSD it errors out.
When I get the Save As dialog, Photoshop wants to save as a copy. Could this be why it's forcing the dialog? And if so any way to disable it?
Copy link to clipboard
Copied
YakZSmelk wrote:
The save as changed your .rgb to .sgi. When I used save as to save a a .SGI when I opened that sgi file it had two alpha channels.I don't know what would cause that.
A few things I noticed;
In your samples, the PSD isn't saved yet. If I run the script with an unsaved PSD it errors out.
When I get the Save As dialog, Photoshop wants to save as a copy. Could this be why it's forcing the dialog? And if so any way to disable it?
My psd is saved for there would no blacking file no Path or Parent path if not save the script would fail with the document has not been saved.
saveOptions.typename is read only your set does not through an error and does not change the setting.
Photoshop is changing .rgb to .sgi I do not know why I would think it the Plug-in doing that. I do not see copy in either name I do see the .rgb is .sgi in the files saved.
My testing is on Windows 10 CC 2017. There are bugs in CC 2017 .....
#target photoshop
var AD = activeDocument;
var docPath = AD.path;
var docName = AD.name;
var savePath = new Folder (docPath.parent);
var saveName = docName.substring(0 , docName.length - 4);
//Layers that should be saved out
var layerNight = AD.artLayers.getByName("NIGHT");
var layerColor = AD.artLayers.getByName("COLOR");
//This is the savepath and name the file will be saved under
nightFile = new File(savePath + "/" + saveName + "_night.rgb")
colorFile = new File(savePath + "/" + saveName + "\.rgb")
//Find the document's height for resizing
var docHeight = AD.height;
var docWidth = AD.width;
var savedState = AD.activeHistoryState;
//FILE OPTIONS
//SGIRGB Save Options
saveOptions = new SGIRGBSaveOptions();
saveOptions.spotColors = false;
saveOptions.alphaChannels = true;
saveOptions.typename = false;
alert("saveOptions.typename = " + saveOptions.typename); //it is read only
saveNight ();
saveColor ();
layerNight.visible = true;
layerColor.visible = true;
//Function for saving the Night Data
function saveNight (){
//Toggles required layer on and other off to make sure NIGHT is top layer
layerNight.visible = true;
layerColor.visible = false;
resizeDocument();
saveOptions.alphaChannels = false;
alert("nightFile = " + nightFile + " saveOptions.spotColors = " + saveOptions.spotColors + " saveOptions.alphaChannels = " + saveOptions.alphaChannels );
app.activeDocument.saveAs(nightFile, saveOptions, true,Extension.LOWERCASE);
revertHistory ();
}
//Function for saving the Color Data
function saveColor (){
//Toggles required layer on and other off to make sure COLOR is top layer
layerNight.visible = false;
layerColor.visible = true;
saveOptions.alphaChannels = false;
alert("colorFile = " + colorFile + " saveOptions.spotColors = " + saveOptions.spotColors + " saveOptions.alphaChannels = " + saveOptions.alphaChannels );
app.activeDocument.saveAs(colorFile, saveOptions, true,Extension.LOWERCASE);
}
function resizeDocument(){
//app.activeDocument.suspendHistory ("History Revert", "saveColor()");
app.activeDocument.resizeImage((docWidth/2), (docHeight/2), null, ResampleMethod.NEARESTNEIGHBOR);
}
function revertHistory (){
//'AD.historyState.getByName ("History Revert");
AD.activeHistoryState = savedState;
app.purge (PurgeTarget.HISTORYCACHES);
}