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

PS Script: Fix for Wavelet Decompose.jsx?

Advocate ,
May 20, 2021 May 20, 2021

Some weeks ago I noticed a retoucher had an action for "Wavelet Decompose".

At that time I didn't know it was for frequency separation (which I'm not really needing much, or mastering yet), so out of curiosity I Googled and found this script ...

 

https://github.com/coderand/photoshop

 

IIRC, it still works in PS 2019, but in my PS 21.2.4 it doesn't.

It is supposed to open a new document where it will make the requested layers. This is where it seems to get stuck in newer versions of PS...

 

I think the problem might be in this part...

var waveletDoc = app.documents.add(
  app.activeDocument.width,
  app.activeDocument.height,
  app.activeDocument.resolution,
  app.activeDocument.name + "-" + activeLayer.name + "-Wavelet",
  NewDocumentMode.RGB, DocumentFill.TRANSPARENT,
  app.activeDocument.pixelAspectRatio,
  BitsPerChannelType.SIXTEEN
);

 

If you see an obvious mismatch for newer PS versions, please suggest a change.

OTOH, I don't really need this at all (AFAIK), so don't waste your time for me... 😉

TOPICS
Actions and scripting
4.6K
Translate
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 , May 20, 2021 May 20, 2021

Remove percentages from the ruler. This is the problem.

Translate
Adobe
Community Expert ,
May 20, 2021 May 20, 2021

Try 

var waveletDoc = app.documents.add(
  app.activeDocument.width,
  app.activeDocument.height,
  app.activeDocument.resolution,
  app.activeDocument.name + "-" + app.activeDocument.activeLayer.name + "-Wavelet",
  NewDocumentMode.RGB, DocumentFill.TRANSPARENT,
  app.activeDocument.pixelAspectRatio,
  BitsPerChannelType.SIXTEEN
);
Translate
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 ,
May 20, 2021 May 20, 2021

Thx, but no difference, I think.

I see the Select All ants and then it stops, while it should be making a new document...

Translate
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 ,
May 20, 2021 May 20, 2021

Works fine here after rectifying the »activeLayer«. 

What is the error you ger? 

Translate
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 ,
May 20, 2021 May 20, 2021

I don't even get an error, it just stops at the selection...

 

Mind you, I'm in Win 7 still and using the latest mentioned version (w many bugs, IMO).

And who knows I have some nerdy setting that prevents it working somehow...

Good to know it will work on Win 10 then (unless you are on a Mac? 😉 )

In that case, you have kinda solved it, as far as I'm concerned. Thanks! 🙂

Translate
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 ,
May 20, 2021 May 20, 2021

Are you using ESTK or Visual Studio Code to troubleshoot the code? 

 

Edit: I work on Mac, by the way. 

Translate
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 ,
May 20, 2021 May 20, 2021

I just use Extend Script Tookit and old brain... 😉

 

I don't even know if you can use that to go through the code line by line?

I've used such luxury in the old days but for the stuff I'm actually programming in my latter years, I've hardly wondered if it's available, cos I usually don't need it.

It might be dead simple and I'd beat myself to death... 😜

Translate
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 ,
May 20, 2021 May 20, 2021

But does ExtendScript not gove a line about the error? 

Could you please post a screenshot? 

Translate
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 ,
May 20, 2021 May 20, 2021

I just save the script and run it inside PS, as I've not been very aware you could do this in EST.

Let me look into that for a sec 🙂

 

A screenschot in PS would simply be: no changes except Select All ants...

cat.jpg

 

It's like the New Document is prevented.

I've explicitly made sure the updated script is loaded...

Translate
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 ,
May 20, 2021 May 20, 2021

So I've used F5 to run it for the first time ever, and it shows this...

ExtendScript_Toolkit_mm1aMmaC9O.jpg

Translate
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 ,
May 20, 2021 May 20, 2021

Tried again and now it highlights...

ExtendScript_Toolkit_mm1aMmaC9O.jpg

 

Yesterday I had a weird thing where and action/script would once work correctly, then wrongly, then correctly, etc.

Yet, I'm not ready to ditch my Prefs file yet... 😛

Translate
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 ,
May 20, 2021 May 20, 2021

Tried again, and now...

ExtendScript_Toolkit_qJq9WOcy6O.jpg

This Debug mode seems to give just random results...

Translate
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 ,
May 20, 2021 May 20, 2021

Made sure to do the EXACT same thing and it stopped 3 times at this last one ^

Translate
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 ,
May 20, 2021 May 20, 2021

Sorry, I've uploaded the wrong screenshot for the 2nd one. It was also like the last one.

I think the difference was maybe cos I forgot to deselect inside PS before testing again.

Translate
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 ,
May 20, 2021 May 20, 2021
The script works without errors on win7 and PS21.2.2.
You may have made a mistake while copying the script text.
 
What are the parameters of your open document?
 
 
 
Translate
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 ,
May 20, 2021 May 20, 2021

Good to know, thx.

 

I am both meticulous *and* making many mistakes... 😉

I think I've literally retyped the commas now and everything 🙂

I'm using the original code with (or without) c.p's correction.  Nothing helps...

 

ExtendScript_Toolkit_2Nug3WMTWx.jpg

 

In PS 2019 it worked with anyhing.

I'm usually using fairly small pics in RGB 8-bit.

Translate
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 ,
May 20, 2021 May 20, 2021

use this code of function (added try-catch)

function generateWavelets( levelCount, addExtraControls ) 
    {
    try {
        levelCount = parseInt( levelCount, 10 );
        var activeLayer = app.activeDocument.activeLayer;
    
        app.activeDocument.selection.selectAll();
    
        try { app.activeDocument.selection.copy( true ); }
        catch (e) {
            try { app.activeDocument.selection.copy(); }
            catch (e) { alert(e); }
        }
    
        var waveletDoc = app.documents.add(
            app.activeDocument.width,
            app.activeDocument.height,
            app.activeDocument.resolution,
            app.activeDocument.name + "-" + activeLayer.name + "-Wavelet",
            NewDocumentMode.RGB, DocumentFill.TRANSPARENT,
            app.activeDocument.pixelAspectRatio,
            BitsPerChannelType.SIXTEEN
            );
    
        try { app.activeDocument.suspendHistory("Wavelet", "generateDocWavelets( waveletDoc, levelCount, addExtraControls )") }
        catch(e) { alert(e); } 
        }
    catch(e) { alert(e); }     
    }

 

Translate
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 ,
May 20, 2021 May 20, 2021

Photoshop_RTy1VMBoLI.jpg

Translate
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 ,
May 20, 2021 May 20, 2021

Replace the last 

catch(e) { alert(e); }  

 

on the

catch (e) { alert(e.message + "\n\nline: " + e.line + "\n\n" + e.source.split("\n")[e.line-1].replace(/^\s+/g, "")); }

 

and show the messаge

Translate
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 ,
May 20, 2021 May 20, 2021

Photoshop_ke9vVPxPlB.jpg

 

Do you think some panels could interfere that hack stuff and try to watch over things that are happening?

I'm lazy so far to try with those removed. I may have one or two...

Translate
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 ,
May 20, 2021 May 20, 2021

BTW, this new code seems to crash PS badly 2 times in a row...

Translate
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 ,
May 20, 2021 May 20, 2021

3rd time it didn't crash.  I hope it wasn't the Select All I forgot again...

I'll put a Deselect and the script into an action...

Translate
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 ,
May 20, 2021 May 20, 2021

Remove percentages from the ruler. This is the problem.

Translate
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 ,
May 20, 2021 May 20, 2021

That does it!! 🙂

 

You BIN there, done that? 😉

 

I usually don't have it set to that, but some of my scripts change it, and maybe interrupting one left it so.

I know how to add and reset that stuff via the script.

 

WOW!  Great catch and TYVM 🙂

Translate
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 ,
May 20, 2021 May 20, 2021
LATEST

I wanted to suggest the same after your other post, but then found you did it yourself 😉

Translate
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