Skip to main content
Participant
December 15, 2016
Question

SGIRGB Skipping SaveAs Dialog

  • December 15, 2016
  • 2 replies
  • 665 views

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.

This topic has been closed for replies.

2 replies

JavierAroche
Inspiring
December 15, 2016

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.

YakZSmelkAuthor
Participant
December 15, 2016

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);

}

JJMack
Community Expert
Community Expert
December 15, 2016

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.

JJMack
JJMack
Community Expert
Community Expert
December 15, 2016

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

JJMack