Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Setting SaveForWeb Metadata option

Contributor ,
Mar 08, 2016 Mar 08, 2016

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!

TOPICS
Actions and scripting
795
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Expert ,
Mar 08, 2016 Mar 08, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Mar 08, 2016 Mar 08, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 08, 2016 Mar 08, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 08, 2016 Mar 08, 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 );

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Mar 08, 2016 Mar 08, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 08, 2016 Mar 08, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Mar 08, 2016 Mar 08, 2016

Sorry, I don't see how I'm supposed to create code that looks like:

exportOptions.metadata = "all";
from

desc3.putEnumerated( idSWmd, idSTmd, idMDAl );

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 08, 2016 Mar 08, 2016

You don't, it's all ready set for All. You just take all the code up there - it would be better if you used scriptlistener to record all the exact settings you want - and wrap it in a function, and substitute the path and file name in line 13 with a variable that you can change with your script. Nothing to rewrite other than the variable for the path name.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Mar 09, 2016 Mar 09, 2016

Ok, I'm still trying to figure out what to do with the code, but I thought I'd try the listener script anyways.  I open the saveForWeb dialog, change the mode to "none" for meta data, and hit done.  Then I reopen the modal, change it to "all" and hit "done".  It's obviously saving the preference when I hit done, but I see no difference in the listener code:

None:

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

var idExpr = charIDToTypeID( "Expr" );

    var desc6 = new ActionDescriptor();

    var idUsng = charIDToTypeID( "Usng" );

        var desc7 = new ActionDescriptor();

        var idOp = charIDToTypeID( "Op  " );

        var idSWOp = charIDToTypeID( "SWOp" );

        var idOpRe = charIDToTypeID( "OpRe" );

        desc7.putEnumerated( idOp, idSWOp, idOpRe );

        var idFmt = charIDToTypeID( "Fmt " );

        var idIRFm = charIDToTypeID( "IRFm" );

        var idPNtwofour = charIDToTypeID( "PN24" );

        desc7.putEnumerated( idFmt, idIRFm, idPNtwofour );

        var idIntr = charIDToTypeID( "Intr" );

        desc7.putBoolean( idIntr, false );

        var idTrns = charIDToTypeID( "Trns" );

        desc7.putBoolean( idTrns, true );

        var idMtt = charIDToTypeID( "Mtt " );

        desc7.putBoolean( idMtt, false );

        var idEICC = charIDToTypeID( "EICC" );

        desc7.putBoolean( idEICC, false );

        var idMttR = charIDToTypeID( "MttR" );

        desc7.putInteger( idMttR, 255 );

        var idMttG = charIDToTypeID( "MttG" );

        desc7.putInteger( idMttG, 255 );

        var idMttB = charIDToTypeID( "MttB" );

        desc7.putInteger( idMttB, 255 );

    var idSaveForWeb = stringIDToTypeID( "SaveForWeb" );

    desc6.putObject( idUsng, idSaveForWeb, desc7 );

executeAction( idExpr, desc6, DialogModes.NO );

All:

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

var idExpr = charIDToTypeID( "Expr" );

    var desc8 = new ActionDescriptor();

    var idUsng = charIDToTypeID( "Usng" );

        var desc9 = new ActionDescriptor();

        var idOp = charIDToTypeID( "Op  " );

        var idSWOp = charIDToTypeID( "SWOp" );

        var idOpRe = charIDToTypeID( "OpRe" );

        desc9.putEnumerated( idOp, idSWOp, idOpRe );

        var idFmt = charIDToTypeID( "Fmt " );

        var idIRFm = charIDToTypeID( "IRFm" );

        var idPNtwofour = charIDToTypeID( "PN24" );

        desc9.putEnumerated( idFmt, idIRFm, idPNtwofour );

        var idIntr = charIDToTypeID( "Intr" );

        desc9.putBoolean( idIntr, false );

        var idTrns = charIDToTypeID( "Trns" );

        desc9.putBoolean( idTrns, true );

        var idMtt = charIDToTypeID( "Mtt " );

        desc9.putBoolean( idMtt, false );

        var idEICC = charIDToTypeID( "EICC" );

        desc9.putBoolean( idEICC, false );

        var idMttR = charIDToTypeID( "MttR" );

        desc9.putInteger( idMttR, 255 );

        var idMttG = charIDToTypeID( "MttG" );

        desc9.putInteger( idMttG, 255 );

        var idMttB = charIDToTypeID( "MttB" );

        desc9.putInteger( idMttB, 255 );

    var idSaveForWeb = stringIDToTypeID( "SaveForWeb" );

    desc8.putObject( idUsng, idSaveForWeb, desc9 );

executeAction( idExpr, desc8, DialogModes.NO );

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Mar 09, 2016 Mar 09, 2016

Also, and I thought this was interesting, since "Save For Web" says "legacy", I tried using "Export" instead, and the listener saves no commands, which makes me think "Export" is done outside of PS?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Mar 09, 2016 Mar 09, 2016

Going back to the legacy "Save For Web", I think I got it to work.  I use the modal to set it to "none" for metadata export, then I run this:

var idExpr = charIDToTypeID( "Expr" ); 

     var desc2 = new ActionDescriptor(); 

          var desc3 = new ActionDescriptor();

          var idUsng = charIDToTypeID( "Usng" ); 

          var idOp = charIDToTypeID( "Op  " );

          var idSWOp = charIDToTypeID( "SWOp" );

          var idOpRe = charIDToTypeID( "OpRe" );

          desc3.putEnumerated( idOp, idSWOp, idOpRe );

          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 idSaveForWeb = stringIDToTypeID( "SaveForWeb" ); 

     desc2.putObject( idUsng, idSaveForWeb, desc3 ); 

executeAction( idExpr, desc2, DialogModes.NO );

... and it changes the metadata export to "all" .  Next time I open the dialog, there it is.  The idOp seems to be what tells it not to think it should actually be saving, mimicking the "done" button.  So, thanks!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 09, 2016 Mar 09, 2016

No problem. While playing around with this, I did run into an issue with changing the file path. No matter what variable I put in it would not save to it. It kept saving to the root directory for PS 2015. I reported this to Adobe, but haven't heard anything about it yet.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 03, 2024 Jul 03, 2024
LATEST
Try this

exportOptions.
metadata = true;

This is working. I had a similar situation and tried it. 
 
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines