Skip to main content
Participant
December 19, 2014
解決済み

How can i open the "Convert to Indexed Color" dialog with custom presets?

  • December 19, 2014
  • 返信数 1.
  • 323 ビュー

Hi,

I need to automatically open the "Convert to Indexed Colors" dialog in Photoshop. Before and after that i have some scripts running so its not possible to open the dialog manually. Also i want to set some custom presets (like number of colors etc.).

Found something similar to what i want for the Color Range selection (opens the dialog with the presets you put in):

function colorrange(enabled, withDialog, fuzziness) {

    if (enabled != undefined && !enabled)

      return;

    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);

    var desc1 = new ActionDescriptor();

    desc1.putInteger(app.charIDToTypeID('Fzns'),fuzziness);

    var desc2 = new ActionDescriptor();

    desc2.putDouble(app.charIDToTypeID('Lmnc'), 31.22);

    desc2.putDouble(app.stringIDToTypeID("a"), 0.86);

    desc2.putDouble(app.stringIDToTypeID("b"), 0.31);

    desc1.putObject(app.charIDToTypeID('Mnm '), app.charIDToTypeID('LbCl'), desc2);

    var desc3 = new ActionDescriptor();

    desc3.putDouble(app.charIDToTypeID('Lmnc'), 95.34);

    desc3.putDouble(app.stringIDToTypeID("a"), 54.59);

    desc3.putDouble(app.stringIDToTypeID("b"), 49.85);

    desc1.putObject(app.charIDToTypeID('Mxm '), app.charIDToTypeID('LbCl'), desc3);

    desc1.putInteger(app.stringIDToTypeID("colorModel"), 0);

    var desc4 = new ActionDescriptor();

    var desc4 = executeAction(app.stringIDToTypeID('colorRange'), desc1, dialogMode);

  };

How can i achieve the same for the indexed color conversion dialog? Apart from doing a lot of guessing regarding the stringIDs.

Is there some kind of "lookup table" for char and string IDs?

Thank you guys in advance! This forum has been a great help many times.

このトピックへの返信は締め切られました。
解決に役立った回答 blackpainter

Ok never mind i got it, stupid me.

Recorded it with Script Listener and changed the "DialogMode" parameter of the executeAction function from "DialogModes.No" to "DialogModes.All".

var idCnvM = charIDToTypeID( "CnvM" );

            var desc249 = new ActionDescriptor();

            var idT = charIDToTypeID( "T  " );

                var desc250 = new ActionDescriptor();

                var idPlt = charIDToTypeID( "Plt " );

                var idClrP = charIDToTypeID( "ClrP" );

                var idSele = charIDToTypeID( "Sele" );

                desc250.putEnumerated( idPlt, idClrP, idSele );

                var idClrs = charIDToTypeID( "Clrs" );

                desc250.putInteger( idClrs, 4 );

                var idFrcC = charIDToTypeID( "FrcC" );

                var idFrcC = charIDToTypeID( "FrcC" );

                var idNone = charIDToTypeID( "None" );

                desc250.putEnumerated( idFrcC, idFrcC, idNone );

                var idTrns = charIDToTypeID( "Trns" );

                desc250.putBoolean( idTrns, false );

                var idDthr = charIDToTypeID( "Dthr" );

                var idDthr = charIDToTypeID( "Dthr" );

                var idDfsn = charIDToTypeID( "Dfsn" );

                desc250.putEnumerated( idDthr, idDthr, idDfsn );

                var idDthA = charIDToTypeID( "DthA" );

                desc250.putInteger( idDthA, 75 );

            var idIndC = charIDToTypeID( "IndC" );

            desc249.putObject( idT, idIndC, desc250 );

        executeAction( idCnvM, desc249, DialogModes.ALL ); //Change from NO to ALL

返信数 1

blackpainter作成者解決!
Participant
December 19, 2014

Ok never mind i got it, stupid me.

Recorded it with Script Listener and changed the "DialogMode" parameter of the executeAction function from "DialogModes.No" to "DialogModes.All".

var idCnvM = charIDToTypeID( "CnvM" );

            var desc249 = new ActionDescriptor();

            var idT = charIDToTypeID( "T  " );

                var desc250 = new ActionDescriptor();

                var idPlt = charIDToTypeID( "Plt " );

                var idClrP = charIDToTypeID( "ClrP" );

                var idSele = charIDToTypeID( "Sele" );

                desc250.putEnumerated( idPlt, idClrP, idSele );

                var idClrs = charIDToTypeID( "Clrs" );

                desc250.putInteger( idClrs, 4 );

                var idFrcC = charIDToTypeID( "FrcC" );

                var idFrcC = charIDToTypeID( "FrcC" );

                var idNone = charIDToTypeID( "None" );

                desc250.putEnumerated( idFrcC, idFrcC, idNone );

                var idTrns = charIDToTypeID( "Trns" );

                desc250.putBoolean( idTrns, false );

                var idDthr = charIDToTypeID( "Dthr" );

                var idDthr = charIDToTypeID( "Dthr" );

                var idDfsn = charIDToTypeID( "Dfsn" );

                desc250.putEnumerated( idDthr, idDthr, idDfsn );

                var idDthA = charIDToTypeID( "DthA" );

                desc250.putInteger( idDthA, 75 );

            var idIndC = charIDToTypeID( "IndC" );

            desc249.putObject( idT, idIndC, desc250 );

        executeAction( idCnvM, desc249, DialogModes.ALL ); //Change from NO to ALL