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

Script to Make Brush Preset from PNG File

Explorer ,
Dec 14, 2017 Dec 14, 2017

Copy link to clipboard

Copied

Is there a script or action to make abr brush presets from single or layered png files?

Views

751

Translate

Translate

Report

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

correct answers 1 Correct answer

Community Expert , Dec 14, 2017 Dec 14, 2017

Try this script:

#target photoshop

var bName = prompt ('Enter a name for the brush', 'brush 1', 'Create Brush')

if(bName != null){

    var idMk = charIDToTypeID( "Mk  " );

        var desc5 = new ActionDescriptor();

        var idnull = charIDToTypeID( "null" );

            var ref1 = new ActionReference();

            var idBrsh = charIDToTypeID( "Brsh" );

            ref1.putClass( idBrsh );

        desc5.putReference( idnull, ref1 );

        var idUsng = charIDToTypeID( "Usng" );

            var ref2 = n

...

Votes

Translate

Translate
Adobe
Community Expert ,
Dec 14, 2017 Dec 14, 2017

Copy link to clipboard

Copied

Try this script:

#target photoshop

var bName = prompt ('Enter a name for the brush', 'brush 1', 'Create Brush')

if(bName != null){

    var idMk = charIDToTypeID( "Mk  " );

        var desc5 = new ActionDescriptor();

        var idnull = charIDToTypeID( "null" );

            var ref1 = new ActionReference();

            var idBrsh = charIDToTypeID( "Brsh" );

            ref1.putClass( idBrsh );

        desc5.putReference( idnull, ref1 );

        var idUsng = charIDToTypeID( "Usng" );

            var ref2 = new ActionReference();

            var idPrpr = charIDToTypeID( "Prpr" );

            var idfsel = charIDToTypeID( "fsel" );

            ref2.putProperty( idPrpr, idfsel );

            var idDcmn = charIDToTypeID( "Dcmn" );

            var idOrdn = charIDToTypeID( "Ordn" );

            var idTrgt = charIDToTypeID( "Trgt" );

            ref2.putEnumerated( idDcmn, idOrdn, idTrgt );

        desc5.putReference( idUsng, ref2 );

        var idNm = charIDToTypeID( "Nm  " );

        desc5.putString( idNm, bName );

    executeAction( idMk, desc5, DialogModes.NO );

    }

Votes

Translate

Translate

Report

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
Explorer ,
Dec 14, 2017 Dec 14, 2017

Copy link to clipboard

Copied

What you wrote works perfectly if I have one PNG file open, thank-you!  If I have a file open with multiple layers, the script will make a brush out of all the layers combined.  Is there a way around that, or would that require too many complicated changes to the script?

Votes

Translate

Translate

Report

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 ,
Dec 15, 2017 Dec 15, 2017

Copy link to clipboard

Copied

So you want only the selected layer to be made into a brush? Also you want all open documents to be made into brushes?

Votes

Translate

Translate

Report

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
Explorer ,
Dec 16, 2017 Dec 16, 2017

Copy link to clipboard

Copied

I would like to be able to have a file open and maybe it has 10 layers, then have the script make a brush preset out of each layer.  I hope that makes sense. 

Votes

Translate

Translate

Report

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 ,
Dec 16, 2017 Dec 16, 2017

Copy link to clipboard

Copied

Try this script:

#target photoshop

var doc = activeDocument;

doc.activeLayer = doc.layers[0];

var wkL

visLayers ();

for(var i=0;i<doc.layers.length;i++){

    wkL = doc.activeLayer = doc.layers;

    wkL.visible = true;

   

    var bName = prompt ('Enter a name for the brush', 'brush 1', 'Create Brush')

    if(bName != null){

        mkBrush ();

        };

    wkL.visible = false;

    }

for(var i=0;i<doc.layers.length;i++){

    doc.layers.visible = true;

    }

function mkBrush(){

    var idMk = charIDToTypeID( "Mk  " );

        var desc5 = new ActionDescriptor();

        var idnull = charIDToTypeID( "null" );

            var ref1 = new ActionReference();

            var idBrsh = charIDToTypeID( "Brsh" );

            ref1.putClass( idBrsh );

        desc5.putReference( idnull, ref1 );

        var idUsng = charIDToTypeID( "Usng" );

            var ref2 = new ActionReference();

            var idPrpr = charIDToTypeID( "Prpr" );

            var idfsel = charIDToTypeID( "fsel" );

            ref2.putProperty( idPrpr, idfsel );

            var idDcmn = charIDToTypeID( "Dcmn" );

            var idOrdn = charIDToTypeID( "Ordn" );

            var idTrgt = charIDToTypeID( "Trgt" );

            ref2.putEnumerated( idDcmn, idOrdn, idTrgt );

        desc5.putReference( idUsng, ref2 );

        var idNm = charIDToTypeID( "Nm  " );

        desc5.putString( idNm, bName );

    executeAction( idMk, desc5, DialogModes.NO );

    }

function visLayers(){

       var idShw = charIDToTypeID( "Shw " );

        var desc2 = new ActionDescriptor();

        var idnull = charIDToTypeID( "null" );

            var list1 = new ActionList();

                var ref1 = new ActionReference();

                var idLyr = charIDToTypeID( "Lyr " );

                var idOrdn = charIDToTypeID( "Ordn" );

                var idTrgt = charIDToTypeID( "Trgt" );

                ref1.putEnumerated( idLyr, idOrdn, idTrgt );

            list1.putReference( ref1 );

        desc2.putList( idnull, list1 );

        var idTglO = charIDToTypeID( "TglO" );

        desc2.putBoolean( idTglO, true );

    executeAction( idShw, desc2, DialogModes.NO );

    }

Votes

Translate

Translate

Report

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
Explorer ,
Dec 19, 2017 Dec 19, 2017

Copy link to clipboard

Copied

LATEST

Chuck,

Thank-you so much for this script.  Both of them work perfectly.  Sending you Merry Christmas wishes!

Paula

Votes

Translate

Translate

Report

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