Skip to main content
Inspiring
March 8, 2016
Question

Setting SaveForWeb Metadata option

  • March 8, 2016
  • 3 replies
  • 1028 views

Hi,

I don't see anything about this option in the docs.  I'm scripting to resize and write out .png files from .psd files.  I need the metadata preserved.  I can do this if I first manually go into the SaveForWeb dialog and set the Metadata option to "all".  However, I want to force this in the script, for other users, and in case I forget, or my options get trashed.

Here's the relevant section of the script:

exportOptions = new ExportOptionsSaveForWeb ();

exportOptions.format = SaveDocumentType.PNG;

exportOptions.transparency = true;

exportOptions.PNG8 = false;

document.exportDocument (newFile, ExportType.SAVEFORWEB, exportOptions);

document.close (SaveOptions.DONOTSAVECHANGES);

I've tried guessing at:

exportOptions.metadata = "all";

or

exportOptions.metadata = 4;

with no luck.

Any ideas?  Thanks!

This topic has been closed for replies.

3 replies

Inspiring
July 3, 2024
Try this

exportOptions.
metadata = true;

This is working. I had a similar situation and tried it. 
 
Chuck Uebele
Adobe Expert
March 8, 2016

This is the code I got when I did a save for web using scriptlistener. Line 46 has the code for saving all the metadata:

//=======================================================

var idExpr = charIDToTypeID( "Expr" );

    var desc2 = new ActionDescriptor();

    var idUsng = charIDToTypeID( "Usng" );

        var desc3 = new ActionDescriptor();

        var idOp = charIDToTypeID( "Op  " );

        var idSWOp = charIDToTypeID( "SWOp" );

        var idOpSa = charIDToTypeID( "OpSa" );

        desc3.putEnumerated( idOp, idSWOp, idOpSa );

        var idDIDr = charIDToTypeID( "DIDr" );

        desc3.putBoolean( idDIDr, true );

        var idIn = charIDToTypeID( "In  " );

        desc3.putPath( idIn, new File( "C:\\Users\\csuebele\\Pictures" ) );

        var idFmt = charIDToTypeID( "Fmt " );

        var idIRFm = charIDToTypeID( "IRFm" );

        var idPNtwofour = charIDToTypeID( "PN24" );

        desc3.putEnumerated( idFmt, idIRFm, idPNtwofour );

        var idIntr = charIDToTypeID( "Intr" );

        desc3.putBoolean( idIntr, false );

        var idTrns = charIDToTypeID( "Trns" );

        desc3.putBoolean( idTrns, true );

        var idMtt = charIDToTypeID( "Mtt " );

        desc3.putBoolean( idMtt, true );

        var idEICC = charIDToTypeID( "EICC" );

        desc3.putBoolean( idEICC, false );

        var idMttR = charIDToTypeID( "MttR" );

        desc3.putInteger( idMttR, 255 );

        var idMttG = charIDToTypeID( "MttG" );

        desc3.putInteger( idMttG, 255 );

        var idMttB = charIDToTypeID( "MttB" );

        desc3.putInteger( idMttB, 255 );

        var idSHTM = charIDToTypeID( "SHTM" );

        desc3.putBoolean( idSHTM, false );

        var idSImg = charIDToTypeID( "SImg" );

        desc3.putBoolean( idSImg, true );

        var idSWsl = charIDToTypeID( "SWsl" );

        var idSTsl = charIDToTypeID( "STsl" );

        var idSLAl = charIDToTypeID( "SLAl" );

        desc3.putEnumerated( idSWsl, idSTsl, idSLAl );

        var idSWch = charIDToTypeID( "SWch" );

        var idSTch = charIDToTypeID( "STch" );

        var idCHsR = charIDToTypeID( "CHsR" );

        desc3.putEnumerated( idSWch, idSTch, idCHsR );

        var idSWmd = charIDToTypeID( "SWmd" );

        var idSTmd = charIDToTypeID( "STmd" );

        var idMDAl = charIDToTypeID( "MDAl" );// line controlling what meta data is saved

        desc3.putEnumerated( idSWmd, idSTmd, idMDAl );

        var idohXH = charIDToTypeID( "ohXH" );

        desc3.putBoolean( idohXH, false );

        var idohIC = charIDToTypeID( "ohIC" );

        desc3.putBoolean( idohIC, true );

        var idohAA = charIDToTypeID( "ohAA" );

        desc3.putBoolean( idohAA, true );

        var idohQA = charIDToTypeID( "ohQA" );

        desc3.putBoolean( idohQA, true );

        var idohCA = charIDToTypeID( "ohCA" );

        desc3.putBoolean( idohCA, false );

        var idohIZ = charIDToTypeID( "ohIZ" );

        desc3.putBoolean( idohIZ, true );

        var idohTC = charIDToTypeID( "ohTC" );

        var idSToc = charIDToTypeID( "SToc" );

        var idOCzerothree = charIDToTypeID( "OC03" );

        desc3.putEnumerated( idohTC, idSToc, idOCzerothree );

        var idohAC = charIDToTypeID( "ohAC" );

        var idSToc = charIDToTypeID( "SToc" );

        var idOCzerothree = charIDToTypeID( "OC03" );

        desc3.putEnumerated( idohAC, idSToc, idOCzerothree );

        var idohIn = charIDToTypeID( "ohIn" );

        desc3.putInteger( idohIn, -1 );

        var idohLE = charIDToTypeID( "ohLE" );

        var idSTle = charIDToTypeID( "STle" );

        var idLEzerothree = charIDToTypeID( "LE03" );

        desc3.putEnumerated( idohLE, idSTle, idLEzerothree );

        var idohEn = charIDToTypeID( "ohEn" );

        var idSTen = charIDToTypeID( "STen" );

        var idENzerozero = charIDToTypeID( "EN00" );

        desc3.putEnumerated( idohEn, idSTen, idENzerozero );

        var idolCS = charIDToTypeID( "olCS" );

        desc3.putBoolean( idolCS, false );

        var idolEC = charIDToTypeID( "olEC" );

        var idSTst = charIDToTypeID( "STst" );

        var idSTzerozero = charIDToTypeID( "ST00" );

        desc3.putEnumerated( idolEC, idSTst, idSTzerozero );

        var idolWH = charIDToTypeID( "olWH" );

        var idSTwh = charIDToTypeID( "STwh" );

        var idWHzeroone = charIDToTypeID( "WH01" );

        desc3.putEnumerated( idolWH, idSTwh, idWHzeroone );

        var idolSV = charIDToTypeID( "olSV" );

        var idSTsp = charIDToTypeID( "STsp" );

        var idSPzerofour = charIDToTypeID( "SP04" );

        desc3.putEnumerated( idolSV, idSTsp, idSPzerofour );

        var idolSH = charIDToTypeID( "olSH" );

        var idSTsp = charIDToTypeID( "STsp" );

        var idSPzerofour = charIDToTypeID( "SP04" );

        desc3.putEnumerated( idolSH, idSTsp, idSPzerofour );

        var idolNC = charIDToTypeID( "olNC" );

            var list1 = new ActionList();

                var desc4 = new ActionDescriptor();

                var idncTp = charIDToTypeID( "ncTp" );

                var idSTnc = charIDToTypeID( "STnc" );

                var idNCzerozero = charIDToTypeID( "NC00" );

                desc4.putEnumerated( idncTp, idSTnc, idNCzerozero );

            var idSCnc = charIDToTypeID( "SCnc" );

            list1.putObject( idSCnc, desc4 );

                var desc5 = new ActionDescriptor();

                var idncTp = charIDToTypeID( "ncTp" );

                var idSTnc = charIDToTypeID( "STnc" );

                var idNConenine = charIDToTypeID( "NC19" );

                desc5.putEnumerated( idncTp, idSTnc, idNConenine );

            var idSCnc = charIDToTypeID( "SCnc" );

            list1.putObject( idSCnc, desc5 );

                var desc6 = new ActionDescriptor();

                var idncTp = charIDToTypeID( "ncTp" );

                var idSTnc = charIDToTypeID( "STnc" );

                var idNCtwoeight = charIDToTypeID( "NC28" );

                desc6.putEnumerated( idncTp, idSTnc, idNCtwoeight );

            var idSCnc = charIDToTypeID( "SCnc" );

            list1.putObject( idSCnc, desc6 );

                var desc7 = new ActionDescriptor();

                var idncTp = charIDToTypeID( "ncTp" );

                var idSTnc = charIDToTypeID( "STnc" );

                var idNCtwofour = charIDToTypeID( "NC24" );

                desc7.putEnumerated( idncTp, idSTnc, idNCtwofour );

            var idSCnc = charIDToTypeID( "SCnc" );

            list1.putObject( idSCnc, desc7 );

                var desc8 = new ActionDescriptor();

                var idncTp = charIDToTypeID( "ncTp" );

                var idSTnc = charIDToTypeID( "STnc" );

                var idNCtwofour = charIDToTypeID( "NC24" );

                desc8.putEnumerated( idncTp, idSTnc, idNCtwofour );

            var idSCnc = charIDToTypeID( "SCnc" );

            list1.putObject( idSCnc, desc8 );

                var desc9 = new ActionDescriptor();

                var idncTp = charIDToTypeID( "ncTp" );

                var idSTnc = charIDToTypeID( "STnc" );

                var idNCtwofour = charIDToTypeID( "NC24" );

                desc9.putEnumerated( idncTp, idSTnc, idNCtwofour );

            var idSCnc = charIDToTypeID( "SCnc" );

            list1.putObject( idSCnc, desc9 );

        desc3.putList( idolNC, list1 );

        var idobIA = charIDToTypeID( "obIA" );

        desc3.putBoolean( idobIA, false );

        var idobIP = charIDToTypeID( "obIP" );

        desc3.putString( idobIP, """""" );

        var idobCS = charIDToTypeID( "obCS" );

        var idSTcs = charIDToTypeID( "STcs" );

        var idCSzeroone = charIDToTypeID( "CS01" );

        desc3.putEnumerated( idobCS, idSTcs, idCSzeroone );

        var idovNC = charIDToTypeID( "ovNC" );

            var list2 = new ActionList();

                var desc10 = new ActionDescriptor();

                var idncTp = charIDToTypeID( "ncTp" );

                var idSTnc = charIDToTypeID( "STnc" );

                var idNCzeroone = charIDToTypeID( "NC01" );

                desc10.putEnumerated( idncTp, idSTnc, idNCzeroone );

            var idSCnc = charIDToTypeID( "SCnc" );

            list2.putObject( idSCnc, desc10 );

                var desc11 = new ActionDescriptor();

                var idncTp = charIDToTypeID( "ncTp" );

                var idSTnc = charIDToTypeID( "STnc" );

                var idNCtwozero = charIDToTypeID( "NC20" );

                desc11.putEnumerated( idncTp, idSTnc, idNCtwozero );

            var idSCnc = charIDToTypeID( "SCnc" );

            list2.putObject( idSCnc, desc11 );

                var desc12 = new ActionDescriptor();

                var idncTp = charIDToTypeID( "ncTp" );

                var idSTnc = charIDToTypeID( "STnc" );

                var idNCzerotwo = charIDToTypeID( "NC02" );

                desc12.putEnumerated( idncTp, idSTnc, idNCzerotwo );

            var idSCnc = charIDToTypeID( "SCnc" );

            list2.putObject( idSCnc, desc12 );

                var desc13 = new ActionDescriptor();

                var idncTp = charIDToTypeID( "ncTp" );

                var idSTnc = charIDToTypeID( "STnc" );

                var idNConenine = charIDToTypeID( "NC19" );

                desc13.putEnumerated( idncTp, idSTnc, idNConenine );

            var idSCnc = charIDToTypeID( "SCnc" );

            list2.putObject( idSCnc, desc13 );

                var desc14 = new ActionDescriptor();

                var idncTp = charIDToTypeID( "ncTp" );

                var idSTnc = charIDToTypeID( "STnc" );

                var idNCzerosix = charIDToTypeID( "NC06" );

                desc14.putEnumerated( idncTp, idSTnc, idNCzerosix );

            var idSCnc = charIDToTypeID( "SCnc" );

            list2.putObject( idSCnc, desc14 );

                var desc15 = new ActionDescriptor();

                var idncTp = charIDToTypeID( "ncTp" );

                var idSTnc = charIDToTypeID( "STnc" );

                var idNCtwofour = charIDToTypeID( "NC24" );

                desc15.putEnumerated( idncTp, idSTnc, idNCtwofour );

            var idSCnc = charIDToTypeID( "SCnc" );

            list2.putObject( idSCnc, desc15 );

                var desc16 = new ActionDescriptor();

                var idncTp = charIDToTypeID( "ncTp" );

                var idSTnc = charIDToTypeID( "STnc" );

                var idNCtwofour = charIDToTypeID( "NC24" );

                desc16.putEnumerated( idncTp, idSTnc, idNCtwofour );

            var idSCnc = charIDToTypeID( "SCnc" );

            list2.putObject( idSCnc, desc16 );

                var desc17 = new ActionDescriptor();

                var idncTp = charIDToTypeID( "ncTp" );

                var idSTnc = charIDToTypeID( "STnc" );

                var idNCtwofour = charIDToTypeID( "NC24" );

                desc17.putEnumerated( idncTp, idSTnc, idNCtwofour );

            var idSCnc = charIDToTypeID( "SCnc" );

            list2.putObject( idSCnc, desc17 );

                var desc18 = new ActionDescriptor();

                var idncTp = charIDToTypeID( "ncTp" );

                var idSTnc = charIDToTypeID( "STnc" );

                var idNCtwotwo = charIDToTypeID( "NC22" );

                desc18.putEnumerated( idncTp, idSTnc, idNCtwotwo );

            var idSCnc = charIDToTypeID( "SCnc" );

            list2.putObject( idSCnc, desc18 );

        desc3.putList( idovNC, list2 );

        var idovCM = charIDToTypeID( "ovCM" );

        desc3.putBoolean( idovCM, false );

        var idovCW = charIDToTypeID( "ovCW" );

        desc3.putBoolean( idovCW, true );

        var idovCU = charIDToTypeID( "ovCU" );

        desc3.putBoolean( idovCU, true );

        var idovSF = charIDToTypeID( "ovSF" );

        desc3.putBoolean( idovSF, true );

        var idovCB = charIDToTypeID( "ovCB" );

        desc3.putBoolean( idovCB, true );

        var idovSN = charIDToTypeID( "ovSN" );

        desc3.putString( idovSN, """c:\photos""" );

    var idSaveForWeb = stringIDToTypeID( "SaveForWeb" );

    desc2.putObject( idUsng, idSaveForWeb, desc3 );

executeAction( idExpr, desc2, DialogModes.NO );

Inspiring
March 8, 2016

" desc3.putEnumerated( idSWmd, idSTmd, idMDAl ); 

Thanks, but that doesn't do me much good.  I just need the javascript code to do it.  I'm not going to rewrite into whatever actionscript is.

Chuck Uebele
Adobe Expert
March 8, 2016

That is java script code. All you really need to do is put a variable in where the file name is and wrap the whole thing in a function, so you can refer to it numerous times, without having to duplicate the code over and over. I was just pointing out the line that has the metadate info. You don't need to do anything with that.

Chuck Uebele
Adobe Expert
March 8, 2016

I would use Scriptlistener and use action manager code for this. It should run faster and be more accurate as to the settings you want.

Inspiring
March 8, 2016

Never used scriptlistener.  Does it give me the command to do what I want?  I've followed the instructions to "install" it, putting it in an "Automate" directory I made, but nothing seems to happen.

Chuck Uebele
Adobe Expert
March 8, 2016

You put it in the the automate folder, as you said you did, then you have to restart PS. The code it generates is put in a file on the desktop.