Copy link to clipboard
Copied
What if we set the pixel ratio? For example, 1000x1000 pixel is Blur 3 radius pixels. 2000x2000 pixel is blur 6 radius pixels. If it's 1500x1500 pixels, can you make scripts to add how much blur radius... Before clicking the scripts, I'll set the selection with rectangular marquee tools and how many pixels to set.
@Thihasoe531 – Is this related to your similar post below?
If performing frequency separation, it is normally done on the entire canvas, not a selection. It can always be masked afterwards.
// 2023, use it at your own risk;
if (app.documents.length > 0) {
var originalRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
if (hasSelection() == true) {
var theBounds = activeDocument.selection.bounds;
var theWidth = theBounds[2] - theBounds[0];
var theHeight = theBounds[3] - theBounds[1];
var theValue = Math.max(theWidth, theHeight) * 0.003;
gaussianBlur (theValue)
};
app.preferences.rulerUnits
...
// 2024, use it at your own risk;
if (app.documents.length > 0) {
var originalRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
if (hasSelection() == true) {
var theBounds = activeDocument.selection.bounds;
var theWidth = theBounds[2] - theBounds[0];
var theHeight = theBounds[3] - theBounds[1];
var theValue = Math.max(theWidth, theHeight) * 0.003;
surfaceBlur (theValue, 10)
};
app.preferences.rulerUnits
...
For one thing a function that takes three arguments should be fed three arguments.
// 2024, use it at your own risk;
if (app.documents.length > 0) {
var originalRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
if (hasSelection() == true) {
var theBounds = activeDocument.selection.bounds;
var theWidth = theBounds[2] - theBounds[0];
var theHeight = theBounds[3] - theBounds[1];
var theValue = Math.max(theWidth, theHeight) * 0.021;
unsharpMask (120, theValue, 10)
...
Copy link to clipboard
Copied
Are you looking for help with scripting? I will tag few experts who can help you @c.pfaffenbichler @Stephen_A_Marsh
Copy link to clipboard
Copied
You can use the bounds of the active Selection to determine its width and height and then calculate the Filter-value.
But what about non-square Selections? How exactly should those influence the target-value?
Copy link to clipboard
Copied
// 2023, use it at your own risk;
if (app.documents.length > 0) {
var originalRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
if (hasSelection() == true) {
var theBounds = activeDocument.selection.bounds;
var theWidth = theBounds[2] - theBounds[0];
var theHeight = theBounds[3] - theBounds[1];
var theValue = Math.max(theWidth, theHeight) * 0.003;
gaussianBlur (theValue)
};
app.preferences.rulerUnits = originalRulerUnits;
};
////// gaussian blur //////
function gaussianBlur (value) {
try {
var idGsnB = charIDToTypeID( "GsnB" );
var desc4 = new ActionDescriptor();
var idRds = charIDToTypeID( "Rds " );
var idPxl = charIDToTypeID( "#Pxl" );
desc4.putUnitDouble( idRds, idPxl, value );
executeAction( idGsnB, desc4, DialogModes.NO );
app.refresh();
} catch (e) {}
};
////// check for selection //////
function hasSelection(){
var ref10 = new ActionReference();
ref10.putProperty(stringIDToTypeID("property"), stringIDToTypeID("selection"));
ref10.putEnumerated( charIDToTypeID( "Dcmn" ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ) );
var docDesc = executeActionGet(ref10);
return docDesc.hasKey(stringIDToTypeID("selection"));
};
Copy link to clipboard
Copied
@c.pfaffenbichler – that's some pretty good voodoo you have there!
var theValue = Math.max(theWidth, theHeight) * 0.003;
I would have used a whole lot of if/else or other conditionals, which isn't as elegant as your approach!
Copy link to clipboard
Copied
But does it make sense in this process?
It would give the same result for a Selection of 1000px x 10px and a Selection of 1000px x 1000px.
Copy link to clipboard
Copied
Perhaps not!
But it makes as much sense as a one size fits all frequency separation based on pixel dimensions rather than unique image content and further editing requirements.
Copy link to clipboard
Copied
i need this scripts. Thank you so much sir
Copy link to clipboard
Copied
If I want to replace Gaussian Blur with Highpass, how can I fix it in the scripts?
Copy link to clipboard
Copied
You needn’t use AM-code, DOM-code offers the method applyHighPass (edit: for ArtLayer)
Copy link to clipboard
Copied
Is it possible to modify some places in the notepad in the scripts written by Sir? I want to replace the Gaussian Blur with a highpass or something
Copy link to clipboard
Copied
Replace the line
gaussianBlur (theValue)
with
activeDocument.activeLayer.applyHighPass(theValue)
Copy link to clipboard
Copied
Thank you so much sir !
Copy link to clipboard
Copied
If I want to replace Gaussian Blur with Surface Blur, how can I fix it in the scripts?
I tried to change it, but it didn't work... please help me sir
Copy link to clipboard
Copied
You need to use the ScriptingListener plugin for legacy ExtendScript .jsx code that isn't covered by the legacy DOM... Or UXP batchPlay .psjs code if this isn't in the UXP DOM.
EDIT: Here it is in a function for ExtendScript:
surfaceBlur(5, 10);
function surfaceBlur(radius, threshold) {
var s2t = function (s) {
return app.stringIDToTypeID(s);
};
var descriptor = new ActionDescriptor();
descriptor.putUnitDouble( s2t( "radius" ), s2t( "pixelsUnit" ), radius );
descriptor.putInteger( s2t( "threshold" ), threshold );
executeAction( s2t( "surfaceBlur" ), descriptor, DialogModes.NO );
}
Copy link to clipboard
Copied
Hello Sir @c.pfaffenbichler If I want to replace Gaussian Blur with Surface Blur, how can I fix it in the scripts?
I tried to change it, but it didn't work... please help me sir
Copy link to clipboard
Copied
// 2024, use it at your own risk;
if (app.documents.length > 0) {
var originalRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
if (hasSelection() == true) {
var theBounds = activeDocument.selection.bounds;
var theWidth = theBounds[2] - theBounds[0];
var theHeight = theBounds[3] - theBounds[1];
var theValue = Math.max(theWidth, theHeight) * 0.003;
surfaceBlur (theValue, 10)
};
app.preferences.rulerUnits = originalRulerUnits;
};
////// surface blur //////
function surfaceBlur (theRadius, theThreshold) {
try {
var desc4 = new ActionDescriptor();
desc4.putUnitDouble( charIDToTypeID( "Rds " ), charIDToTypeID( "#Pxl" ), theRadius );
desc4.putInteger( charIDToTypeID( "Thsh" ), theThreshold );
executeAction( stringIDToTypeID( "surfaceBlur" ), desc4, DialogModes.NO );
app.refresh();
} catch (e) {}
};
////// check for selection //////
function hasSelection(){
var ref10 = new ActionReference();
ref10.putProperty(stringIDToTypeID("property"), stringIDToTypeID("selection"));
ref10.putEnumerated( charIDToTypeID( "Dcmn" ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ) );
var docDesc = executeActionGet(ref10);
return docDesc.hasKey(stringIDToTypeID("selection"));
};
Copy link to clipboard
Copied
Thank You So Much Sir @c.pfaffenbichler
Copy link to clipboard
Copied
Hello Sir @c.pfaffenbichler
I tried to fix the scripts for Unsharp Mask but I don't know where I'm going wrong, the usharp mask scripts are unusable, please help me
// 2024, use it at your own risk;
if (app.documents.length > 0) {
var originalRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
if (hasSelection() == true) {
var theBounds = activeDocument.selection.bounds;
var theWidth = theBounds[2] - theBounds[0];
var theHeight = theBounds[3] - theBounds[1];
var theValue = Math.max(theWidth, theHeight) * 0.021;
UnsharpMask (theValue)
};
app.preferences.rulerUnits = originalRulerUnits;
};
////// UnsharpMask //////
function UnsharpMask (theAmount, theRadius, theThreshold) {
try {
var desc1 = new ActionDescriptor();
desc1.putUnitDouble( charIDToTypeID( "Amnt " ), charIDToTypeID( "#Prc" ), theAmount );
desc1.putUnitDouble( charIDToTypeID( "Rds " ), charIDToTypeID( "#Pxl" ), theRadius );
desc1.putInteger( charIDToTypeID( "Thsh" ), theThreshold );
executeAction( stringIDToTypeID( "UnsharpMask" ), desc1, DialogModes.NO );
app.refresh();
} catch (e) {}
};
////// check for selection //////
function hasSelection(){
var ref10 = new ActionReference();
ref10.putProperty(stringIDToTypeID("property"), stringIDToTypeID("selection"));
ref10.putEnumerated( charIDToTypeID( "Dcmn" ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ) );
var docDesc = executeActionGet(ref10);
return docDesc.hasKey(stringIDToTypeID("selection"));
};
Copy link to clipboard
Copied
For one thing a function that takes three arguments should be fed three arguments.
// 2024, use it at your own risk;
if (app.documents.length > 0) {
var originalRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
if (hasSelection() == true) {
var theBounds = activeDocument.selection.bounds;
var theWidth = theBounds[2] - theBounds[0];
var theHeight = theBounds[3] - theBounds[1];
var theValue = Math.max(theWidth, theHeight) * 0.021;
unsharpMask (120, theValue, 10)
};
app.preferences.rulerUnits = originalRulerUnits;
};
////// unsharp mask //////
function unsharpMask (amount, radius, threshold) {
var desc2 = new ActionDescriptor();
desc2.putUnitDouble( idAmnt = charIDToTypeID( "Amnt" ), charIDToTypeID( "#Prc" ), amount );
desc2.putUnitDouble( charIDToTypeID( "Rds " ), charIDToTypeID( "#Pxl" ), radius );
desc2.putInteger( charIDToTypeID( "Thsh" ), threshold );
executeAction( charIDToTypeID( "UnsM" ), desc2, DialogModes.NO);
};
////// check for selection //////
function hasSelection(){
var ref10 = new ActionReference();
ref10.putProperty(stringIDToTypeID("property"), stringIDToTypeID("selection"));
ref10.putEnumerated( charIDToTypeID( "Dcmn" ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ) );
var docDesc = executeActionGet(ref10);
return docDesc.hasKey(stringIDToTypeID("selection"));
};
Copy link to clipboard
Copied
Thank you so much for explaining so thoroughly... I understand . . .
Thank You Sir @c.pfaffenbichler
Copy link to clipboard
Copied
@Thihasoe531 – Is this related to your similar post below?
If performing frequency separation, it is normally done on the entire canvas, not a selection. It can always be masked afterwards.
Copy link to clipboard
Copied
@Stephen A Marsh ... Yes bro ... I want to Creat Skin smoothness automatically Action
Copy link to clipboard
Copied
There are no magic numbers, although resolution plays a part, it is all about the level of detail that is required in the HF layer vs. the LF layer.
Copy link to clipboard
Copied
Yes, gaussian blur radius is not a magic number. . . But in order to separate the image from the low layer and the high layer, we have to adjust the gaussian blur radius again.
For example, in a 4000x6000 pixel image, a close-up face image is blurred by adding a blur radius more than normal when dividing the lw layer vs high layer.
If that 4000x6000 image has a full body image, the blur number should be used a little bit. thank you sir