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... 😉
Remove percentages from the ruler. This is the problem.
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
);
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...
Copy link to clipboard
Copied
Works fine here after rectifying the »activeLayer«.
What is the error you ger?
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! 🙂
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.
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... 😜
Copy link to clipboard
Copied
But does ExtendScript not gove a line about the error?
Could you please post a screenshot?
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...
It's like the New Document is prevented.
I've explicitly made sure the updated script is loaded...
Copy link to clipboard
Copied
So I've used F5 to run it for the first time ever, and it shows this...
Copy link to clipboard
Copied
Tried again and now it highlights...
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... 😛
Copy link to clipboard
Copied
Tried again, and now...
This Debug mode seems to give just random results...
Copy link to clipboard
Copied
Made sure to do the EXACT same thing and it stopped 3 times at this last one ^
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.
Copy link to clipboard
Copied
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...
In PS 2019 it worked with anyhing.
I'm usually using fairly small pics in RGB 8-bit.
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); }
}
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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...
Copy link to clipboard
Copied
BTW, this new code seems to crash PS badly 2 times in a row...
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...
Copy link to clipboard
Copied
Remove percentages from the ruler. This is the problem.
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 🙂
Copy link to clipboard
Copied
I wanted to suggest the same after your other post, but then found you did it yourself 😉