PS Script: Fix for Wavelet Decompose.jsx?

Contributor ,
May 20, 2021 May 20, 2021

Copy link to clipboard

Copied

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

Views

2.2K

Likes

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

Adobe Community Professional , May 20, 2021 May 20, 2021
Remove percentages from the ruler. This is the problem.

Likes

Translate

Translate
Adobe Community Professional ,
May 20, 2021 May 20, 2021

Copy link to clipboard

Copied

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
);

Likes

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

Copy link to clipboard

Copied

Thx, but no difference, I think.

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

Likes

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
Adobe Community Professional ,
May 20, 2021 May 20, 2021

Copy link to clipboard

Copied

Works fine here after rectifying the »activeLayer«. 

What is the error you ger? 

Likes

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

Copy link to clipboard

Copied

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! 🙂

Likes

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
Adobe Community Professional ,
May 20, 2021 May 20, 2021

Copy link to clipboard

Copied

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

 

Edit: I work on Mac, by the way. 

Likes

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

Copy link to clipboard

Copied

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... 😜

Likes

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
Adobe Community Professional ,
May 20, 2021 May 20, 2021

Copy link to clipboard

Copied

But does ExtendScript not gove a line about the error? 

Could you please post a screenshot? 

Likes

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

Copy link to clipboard

Copied

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...

Likes

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

Copy link to clipboard

Copied

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

ExtendScript_Toolkit_mm1aMmaC9O.jpg

Likes

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

Copy link to clipboard

Copied

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... 😛

Likes

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

Copy link to clipboard

Copied

Tried again, and now...

ExtendScript_Toolkit_qJq9WOcy6O.jpg

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

Likes

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

Copy link to clipboard

Copied

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

Likes

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

Copy link to clipboard

Copied

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.

Likes

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
Adobe Community Professional ,
May 20, 2021 May 20, 2021

Copy link to clipboard

Copied

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?
 
 
 

Likes

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

Copy link to clipboard

Copied

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.

Likes

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
Adobe Community Professional ,
May 20, 2021 May 20, 2021

Copy link to clipboard

Copied

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); }     
    }

 

Likes

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

Copy link to clipboard

Copied

Photoshop_RTy1VMBoLI.jpg

Likes

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
Adobe Community Professional ,
May 20, 2021 May 20, 2021

Copy link to clipboard

Copied

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

Likes

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

Copy link to clipboard

Copied

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...

Likes

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

Copy link to clipboard

Copied

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

Likes

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

Copy link to clipboard

Copied

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...

Likes

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
Adobe Community Professional ,
May 20, 2021 May 20, 2021

Copy link to clipboard

Copied

Remove percentages from the ruler. This is the problem.

Likes

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

Copy link to clipboard

Copied

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 🙂

Likes

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
Adobe Community Professional ,
May 20, 2021 May 20, 2021

Copy link to clipboard

Copied

LATEST

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

Likes

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