Skip to main content
Inspiring
July 17, 2023
Answered

Alternative to the spatter filter, for use with DOM scripting?

  • July 17, 2023
  • 2 replies
  • 378 views

Hi!

 

Would it be possible to accomplish sort of what the spatter filter does (roughening up vector shapes to make them look more true to a pixels based scan), but with objects accessible to DOM scripting? I suppose I could try using interface scripting just for the spatter filter, but I would prefer to use code I actually understand...

 

Thanks!
Joakim

This topic has been closed for replies.
Correct answer Stephen Marsh

@hertze 

 

Like so many things in Photoshop scripting, I don’t believe that it is available via the DOM, which leaves AM code. 

 

Spray Radius = 10

Smoothness = 5

 

 

spatterFilter(10, 5);

function spatterFilter(radiusValue, smoothnessValue) {
var idGEfc = charIDToTypeID( "GEfc" );
    var desc533 = new ActionDescriptor();
    var idGEfk = charIDToTypeID( "GEfk" );
    var idGEft = charIDToTypeID( "GEft" );
    var idspatter = stringIDToTypeID( "spatter" );
    desc533.putEnumerated( idGEfk, idGEft, idspatter );
    var idsprayRadius = stringIDToTypeID( "sprayRadius" );
    desc533.putInteger( idsprayRadius, radiusValue );
    var idsmoothness = stringIDToTypeID( "smoothness" );
    desc533.putInteger( idsmoothness, smoothnessValue );
executeAction( idGEfc, desc533, DialogModes.NO );
}

 

 

EDIT: Another option to roughen is Pixelate > Crystallize

 

crystallizeFilter(3);

function crystallizeFilter(crystallizeValue) {
var idcrystallize = stringIDToTypeID( "crystallize" );
    var desc569 = new ActionDescriptor();
    var idcellSize = stringIDToTypeID( "cellSize" );
    desc569.putInteger( idcellSize, crystallizeValue );
executeAction(idcrystallize, desc569, DialogModes.NO);
}

 

 

2 replies

c.pfaffenbichler
Community Expert
Community Expert
July 18, 2023

I am afraid the alternatives (Displace for example) might ultimately be more bother than the result is worth in this case. 

I would recommend just wrapping the ScriptingListener.plugin-created AM code in a function that takes the two values as arguments. 

hertzeAuthor
Inspiring
July 18, 2023

I'll do that! Thanks!

Stephen Marsh
Community Expert
Stephen MarshCommunity ExpertCorrect answer
Community Expert
July 18, 2023

@hertze 

 

Like so many things in Photoshop scripting, I don’t believe that it is available via the DOM, which leaves AM code. 

 

Spray Radius = 10

Smoothness = 5

 

 

spatterFilter(10, 5);

function spatterFilter(radiusValue, smoothnessValue) {
var idGEfc = charIDToTypeID( "GEfc" );
    var desc533 = new ActionDescriptor();
    var idGEfk = charIDToTypeID( "GEfk" );
    var idGEft = charIDToTypeID( "GEft" );
    var idspatter = stringIDToTypeID( "spatter" );
    desc533.putEnumerated( idGEfk, idGEft, idspatter );
    var idsprayRadius = stringIDToTypeID( "sprayRadius" );
    desc533.putInteger( idsprayRadius, radiusValue );
    var idsmoothness = stringIDToTypeID( "smoothness" );
    desc533.putInteger( idsmoothness, smoothnessValue );
executeAction( idGEfc, desc533, DialogModes.NO );
}

 

 

EDIT: Another option to roughen is Pixelate > Crystallize

 

crystallizeFilter(3);

function crystallizeFilter(crystallizeValue) {
var idcrystallize = stringIDToTypeID( "crystallize" );
    var desc569 = new ActionDescriptor();
    var idcellSize = stringIDToTypeID( "cellSize" );
    desc569.putInteger( idcellSize, crystallizeValue );
executeAction(idcrystallize, desc569, DialogModes.NO);
}

 

 

hertzeAuthor
Inspiring
July 18, 2023

Well, I suppose I've taken DOM scripting as far as I can, then! Thank you for the code! Both functions work wonderfully!