Skip to main content
Participant
April 23, 2014
Answered

SaveAs PBM

  • April 23, 2014
  • 1 reply
  • 957 views

Hello.

I need to save my current active document as a PBM format file via CS6 javascript.

However, I'm running into the problem that there's no PBMSaveOptions object defined that I can pass into the saveAs function.

My output always gets converted to .psd even if I define a .pbm extension.

Anyone know if I need to create a custom Options object or another trick?

Bottom line: there don't seem to be enough SaveOptions objects to cover all the formats Photoshop can save to via the GUI.

The Javascript reference lists these:

BMPSaveOptions

DCS1_SaveOptions

DCS2_SaveOptions

EPSSaveOptions

GIFSaveOptions

JPEGSaveOptions

PDFSaveOptions

PhotoshopSaveOptions

PICTFileSaveOptions

PICTResourceSaveOptions

PixarSaveOptions

PNGSaveOptions

RawSaveOptions

SGIRGBSaveOptions

TargaSaveOptions

TiffSaveOptions

Thanks for any help.

-Len

This topic has been closed for replies.
Correct answer Chuck Uebele

Okay, I did some testing.  Just put the file name you want after the the path name:

desc2.putPath( idIn, new File( "C:\\Users\\len\\Desktop\\MyFile.pmb" ) );

1 reply

Chuck Uebele
Community Expert
Community Expert
April 24, 2014

Have you tried saving a file while using scriptListener, then using the action manager code as a template to save other PBM files?

vorpAuthor
Participant
April 24, 2014

Thanks for the idea.

Yes. I did try that.

The problem I run into there is getting the filename of the current document changed to save to the correct file.

I can alter the path (C:\\Users\\len\\Desktop), but not the filename, by analyzing the generated script code (below).

Here's what it output:

var idsave = charIDToTypeID( "save" );

    var desc2 = new ActionDescriptor();

    var idAs = charIDToTypeID( "As  " );

    desc2.putString( idAs, """Portable Bit Map""" );

    var idIn = charIDToTypeID( "In  " );

    desc2.putPath( idIn, new File( "C:\\Users\\len\\Desktop" ) );

    var idDocI = charIDToTypeID( "DocI" );

    desc2.putInteger( idDocI, 37 );

    var idCpy = charIDToTypeID( "Cpy " );

    desc2.putBoolean( idCpy, true );

    var idsaveStage = stringIDToTypeID( "saveStage" );

    var idsaveStageType = stringIDToTypeID( "saveStageType" );

    var idsaveBegin = stringIDToTypeID( "saveBegin" );

    desc2.putEnumerated( idsaveStage, idsaveStageType, idsaveBegin );

executeAction( idsave, desc2, DialogModes.NO );

Chuck Uebele
Community Expert
Community Expert
April 24, 2014

Excellent! That worked, thanks!


Great!  Glad it worked for you.