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

slider blur

Advocate ,
Oct 10, 2017 Oct 10, 2017

Copy link to clipboard

Copied

I have some trouble with this little script

The problem is that if I put blur at 10 and then return to 0

it does not take the blur

where is wrong?

var box = new Window('dialog', "blur"); 

box.panel = box.add('panel', undefined, "Gaussian Blur");

box.panel.group = box.panel.add('group', undefined );

box.panel.group.orientation='row';

box.panel.group.text1 = box.panel.group.add('statictext', undefined, "radius:");

var slider = box.panel.group.add("slider",undefined, 0, 0, 255);

var value = box.panel.group.add('edittext', undefined, "0");

box.panel.group2 = box.panel.add('group', undefined );

box.panel.group2.orientation='row';

box.panel.group2.okBtn = box.panel.group2.add('button',undefined, "ok", {name:'ok'});

box.panel.group2.closeBtn = box.panel.group2.add('button',undefined, "cancel", {name:'cancel'});

slider.onChanging = function () {

value.text = slider.value;

var r = value.text;

blur(r);

app.refresh();

  }

value.onChanging = function () {

slider.value = value.text;

var r = slider.value;

blur(r);

app.refresh();

    }

box.panel.group2.okBtn.onClick = function(){

  slider.onChanging();

  box.close();

}

box.panel.group2.closeBtn.onClick = function(){

  box.close();

}

box.center();

box.show()

function  blur(r){

var idGsnB = charIDToTypeID( "GsnB" );

    var desc14 = new ActionDescriptor();

    var idRds = charIDToTypeID( "Rds " );

    var idPxl = charIDToTypeID( "#Pxl" );

    desc14.putUnitDouble( idRds, idPxl, r );

executeAction( idGsnB, desc14, DialogModes.NO );

    }

TOPICS
Actions and scripting

Views

1.7K

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

People's Champ , Mar 18, 2018 Mar 18, 2018

Try this code

var curr_blur = 0

var box = new Window('dialog', "blur");  

with (box.add('panel', undefined, "Gaussian Blur"))

    { 

    with (add('group')) 

        {

        orientation='row'; 

        add('statictext', undefined, "radius:"); 

        var slider = add("slider",undefined, 0, 0, 255);

        slider.preferredSize.width = 256;

        var value = add('edittext', undefined, curr_blur); 

        value.preferredSize.width = 40;

        }

    with (add('group'))

        { 

        orientatio

...

Votes

Translate

Translate
Adobe
Community Expert ,
Oct 10, 2017 Oct 10, 2017

Copy link to clipboard

Copied

You do not seem to have included any undo or return to a history state, so what do you expect?

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 ,
Oct 10, 2017 Oct 10, 2017

Copy link to clipboard

Copied

When creating a dialog that is supposed to work on an image while still being open one needs to keep in mind whether the operations have an accumulative effect and act accordingly; but also keep in mind that if the dialog gets canceled the operations may be expected to get undone.

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
Advocate ,
Oct 11, 2017 Oct 11, 2017

Copy link to clipboard

Copied

Thanks for the answers

I tried adding historystate and improved a bit

but it is not good yet?

var box = new Window('dialog', "blur");   

box.panel = box.add('panel', undefined, "Gaussian Blur");  

 

box.panel.group = box.panel.add('group', undefined );  

box.panel.group.orientation='row';  

 

box.panel.group.text1 = box.panel.group.add('statictext', undefined, "radius:");  

var slider = box.panel.group.add("slider",undefined, 0, 0, 255); 

var value = box.panel.group.add('edittext', undefined, "0");  

 

box.panel.group2 = box.panel.add('group', undefined );  

box.panel.group2.orientation='row';  

 

box.panel.group2.okBtn = box.panel.group2.add('button',undefined, "ok", {name:'ok'}); 

box.panel.group2.closeBtn = box.panel.group2.add('button',undefined, "cancel", {name:'cancel'});  

 

 

var doc = app.activeDocument; 

var lay = doc.activeLayer; 

var currentStatus = doc.activeHistoryState; 

 

slider.onChanging = function () { 

doc.activeHistoryState = currentStatus; 

value.text = slider.value; 

var r = value.text; 

blur(r); 

app.refresh(); 

  } 

 

value.onChanging = function () { 

doc.activeHistoryState = currentStatus; 

slider.value = value.text; 

var r = slider.value; 

blur(r); 

app.refresh(); 

    } 

 

box.panel.group2.okBtn.onClick = function(){  

  slider.onChanging();  

  box.close(); 

box.panel.group2.closeBtn.onClick = function(){ 

  box.close();  

}  

box.center(); 

box.show() 

 

function  blur(r){  

var idGsnB = charIDToTypeID( "GsnB" ); 

    var desc14 = new ActionDescriptor(); 

    var idRds = charIDToTypeID( "Rds " ); 

    var idPxl = charIDToTypeID( "#Pxl" ); 

    desc14.putUnitDouble( idRds, idPxl, r ); 

executeAction( idGsnB, desc14, 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
Community Expert ,
Oct 12, 2017 Oct 12, 2017

Copy link to clipboard

Copied

but it is not good yet?

How so?

Do you mean that you have not included a return to the history state at cancelling?

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 ,
Oct 12, 2017 Oct 12, 2017

Copy link to clipboard

Copied

If you catch the result of

box.show()

as a variable you can use that to determine if »OK« or »Cancel« were clicked and have the Script proceed accordingly.

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
Engaged ,
Oct 10, 2017 Oct 10, 2017

Copy link to clipboard

Copied

See also Slider color balance! as an example of a similar issue, i.e. dealing with cumulative effects.

Davide Barranca - PS developer and author
www.ps-scripting.com

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
LEGEND ,
Mar 17, 2018 Mar 17, 2018

Copy link to clipboard

Copied

According to your first code put in line 16th:

function ahS() {

    aD.activeHistoryState = (hS = (aD = activeDocument).historyStates)[hS.length - 2]

}

while between lines 17 & 18 and 35 & 36:

ahS()

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
Advocate ,
Mar 18, 2018 Mar 18, 2018

Copy link to clipboard

Copied

It's not good for me

maybe I put your scripts wrong

can you place them in the starting 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
LEGEND ,
Mar 18, 2018 Mar 18, 2018

Copy link to clipboard

Copied

box.panel.group2.closeBtn = box.panel.group2.add('button',undefined, "cancel", {name:'cancel'});

function ahS() {

     aD.activeHistoryState = (hS = (aD = activeDocument).historyStates)[hS.length - 2]

}

slider.onChanging = function () {

slider.onChanging = function () {

     ahS()

     value.text = slider.value;

box.panel.group2.closeBtn.onClick = function(){

     ahS()

     box.close();

You may also put ahS() inside value.onChanging = function()

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
Advocate ,
Mar 18, 2018 Mar 18, 2018

Copy link to clipboard

Copied

I tried it but it does not work

var box = new Window('dialog', "blur");   

box.panel = box.add('panel', undefined, "Gaussian Blur");  

 

box.panel.group = box.panel.add('group', undefined );  

box.panel.group.orientation='row';  

 

box.panel.group.text1 = box.panel.group.add('statictext', undefined, "radius:");  

var slider = box.panel.group.add("slider",undefined, 0, 0, 255); 

var value = box.panel.group.add('edittext', undefined, "0");  

 

box.panel.group2 = box.panel.add('group', undefined );  

box.panel.group2.orientation='row';  

 

box.panel.group2.okBtn = box.panel.group2.add('button',undefined, "ok", {name:'ok'}); 

box.panel.group2.closeBtn = box.panel.group2.add('button',undefined, "cancel", {name:'cancel'}); 

 

function ahS() { 

     aD.activeHistoryState = (hS = (aD = activeDocument).historyStates)[hS.length - 2] 

}

 

slider.onChanging = function () { 

     ahS() 

value.text = slider.value; 

var r = value.text; 

blur(r); 

app.refresh(); 

  } 

 

value.onChanging = function () { 

    ahS() 

slider.value = value.text; 

var r = slider.value; 

blur(r); 

app.refresh(); 

    } 

 

box.panel.group2.okBtn.onClick = function(){  

  slider.onChanging();  

  box.close(); 

box.panel.group2.closeBtn.onClick = function(){ 

     ahS()

  box.close();  

}  

box.center(); 

box.show() 

 

function  blur(r){  

var idGsnB = charIDToTypeID( "GsnB" ); 

    var desc14 = new ActionDescriptor(); 

    var idRds = charIDToTypeID( "Rds " ); 

    var idPxl = charIDToTypeID( "#Pxl" ); 

    desc14.putUnitDouble( idRds, idPxl, r ); 

executeAction( idGsnB, desc14, 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
LEGEND ,
Mar 18, 2018 Mar 18, 2018

Copy link to clipboard

Copied

I copied this code you just pasted and tried it in CS6 EXTENDED and CC2018 (19.1.2) - in both versions that worked very well.

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
Advocate ,
Mar 18, 2018 Mar 18, 2018

Copy link to clipboard

Copied

Kukurykus  ha scritto

I copied this code you just pasted and tried it in CS6 EXTENDED and CC2018 (19.1.2) - in both versions that worked very well.

I use mac with high sierra

maybe this is the problem?

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
LEGEND ,
Mar 18, 2018 Mar 18, 2018

Copy link to clipboard

Copied

I have some trouble with this little script

The problem is that if I put blur at 10 and then return to 0

it does not take the blur

That has no sense, as with your first script when I changed blur to 10 and then back to 0, then blur level was still at 10 level.

With modified by me script now when you put pointer at 10 and again at 0, then blur effect is reverted, so the blur level is 0.

I guess I know what you want but there's mistake in your question. That should be logically asked: 'it does not take the blur'

It might be because of 'high sierra' - Many people reported some bugs about at: Photoshop Family Customer Community

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
People's Champ ,
Mar 18, 2018 Mar 18, 2018

Copy link to clipboard

Copied

del

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
LEGEND ,
Mar 18, 2018 Mar 18, 2018

Copy link to clipboard

Copied

I tested it, there was lack of one line:

currentStatus = (doc = activeDocument).activeHistoryState;

currentStatus = (doc = activeDocument)

.activeHistoryState; var active = false

slider.onChanging = function () {

     if (active) return

     active = true

     doc.activeHistoryState = currentStatus

     value.text = slider.value

     var r = value.text

     blur(r)

     app.refresh()

     active = false

}

Edit: I didn't see you deleted it meantime, should I delete it too?

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
People's Champ ,
Mar 18, 2018 Mar 18, 2018

Copy link to clipboard

Copied

There everything does not work right. Maybe later I'll see what I can do.

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
People's Champ ,
Mar 18, 2018 Mar 18, 2018

Copy link to clipboard

Copied

LATEST

Try this code

var curr_blur = 0

var box = new Window('dialog', "blur");  

with (box.add('panel', undefined, "Gaussian Blur"))

    { 

    with (add('group')) 

        {

        orientation='row'; 

        add('statictext', undefined, "radius:"); 

        var slider = add("slider",undefined, 0, 0, 255);

        slider.preferredSize.width = 256;

        var value = add('edittext', undefined, curr_blur); 

        value.preferredSize.width = 40;

        }

    with (add('group'))

        { 

        orientation='row'; 

        spacing = 70;

        var okBtn = add('button',undefined, "ok", {name:'ok'});

        okBtn.preferredSize.width = 100;

        var closeBtn = add('button',undefined, "cancel", {name:'cancel'}); 

        closeBtn.preferredSize.width = 100;

        }

    }

var ok = false;

var doc = app.activeDocument;

var currentStatus = doc.activeHistoryState;

slider.onChange = function ()

    {

    value.text = slider.value.toFixed(0);

    value.onChanging();

    }

slider.onChanging = function ()

    {

    value.text = slider.value.toFixed(0);

    }

value.onChanging = function ()

    {

    var n = Number(value.text);

   

    if (isNaN(n)) { beep(); return; }

    curr_blur = n;

    slider.value = curr_blur;

    box.opacity = 0.7;

    doc.activeHistoryState = currentStatus;

    blur(curr_blur);

    app.refresh();

    box.opacity = 1.0;

    }

okBtn.onClick = function()

    { 

    ok = true;

    box.close();

    }

closeBtn.onClick = function()

    {

    box.close(); 

    } 

function key_handle(e) // in CC2018 does not work correctly, may not be use

    {

    if (!value.active) return;

    switch (e.keyIdentifier)

        {

        case "U+0030":

        case "U+0031":

        case "U+0032":

        case "U+0033":

        case "U+0034":

        case "U+0035":

        case "U+0036":

        case "U+0037":

        case "U+0038":

        case "U+0039":

        case "U+002E":

        case "U+0008":

        case "U+001B":

        case "U+007F":

            return;

        default:

            //alert(e.keyIdentifier)

            e.preventDefault();

            beep();

            return;

        }           

    }

box.addEventListener ("keydown", key_handle, false); // in CC2018 does not work correctly, may not be use

box.center();

box.show()

if (!ok) doc.activeHistoryState = currentStatus;

function  blur(r){ 

var idGsnB = charIDToTypeID( "GsnB" );

    var desc14 = new ActionDescriptor();

    var idRds = charIDToTypeID( "Rds " );

    var idPxl = charIDToTypeID( "#Pxl" );

    desc14.putUnitDouble( idRds, idPxl, r );

executeAction( idGsnB, desc14, 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