Copy link to clipboard
Copied
How to write a javascript code which will create, in active document, white layer and resize that layer on that way that height of white layer is 50% of actual document height, and width is equal to double size of new height of white layer?
Also, I need advice which is the best book for learning javascript for PS for beeginers?
Thanks in advance
That should be able able to be done with a single resize since it all white the not detail to distort. The resize will be all white. The layer you want is 50% of the height and you need to calulate the width pertentage it not 200% like the code posted. It depends on the documents width
...var strtRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
newLayer = app.activeDocument.artLayers.add();
app.activeDocument.selection.selectAll();
fillWhite = new SolidColor;
fillWhite
Copy link to clipboard
Copied
well this should work if i've understood it really!
#target photoshop var newLayer = app.activeDocument.artLayers.add(); //adds layer var color = app.foregroundColor; color.rgb.red = 255; color.rgb.green = 255; color.rgb.blue = 255; app.foregroundColor = color; app.activeDocument.selection.fill(app.foregroundColor, ColorBlendMode.NORMAL, 100, false); // assign white color app.activeDocument.activeLayer.resize(200, 50, AnchorPosition.MIDDLECENTER); // resize |
Copy link to clipboard
Copied
That should be able able to be done with a single resize since it all white the not detail to distort. The resize will be all white. The layer you want is 50% of the height and you need to calulate the width pertentage it not 200% like the code posted. It depends on the documents width
var strtRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
newLayer = app.activeDocument.artLayers.add();
app.activeDocument.selection.selectAll();
fillWhite = new SolidColor;
fillWhite.rgb.red = 255;
fillWhite.rgb.green = 255;
fillWhite.rgb.blue = 255;
app.activeDocument.selection.fill(fillWhite);
activeDocument.selection.deselect();
app.activeDocument.activeLayer.resize(app.activeDocument.height.value/app.activeDocument.width.value*100,50,AnchorPosition.MIDDLECENTER);
app.preferences.rulerUnits = strtRulerUnits;
Copy link to clipboard
Copied
Sorry JJMack you all are legendary count me as noob too since i also counts on google and javascript reference that officials provides. im not such a great yet so thanks for correcting it!
Copy link to clipboard
Copied
They are new also. They may not realize that if the canvas is much taller then its width the new layer may be wider then the canvas and will be clipped by the documents canvas size. Therefor, will not look like it has a 2:1 aspect ratio. Many new user do not realize that layers can be any size except for a Photoshop Background layer which is always canvas size for it does not have support for transparency. The difference between a 3:2 Landscape and a 2:3 Portrait
Copy link to clipboard
Copied
Thanks JJMack, it works...
Do you have any proposal for second part of my question, related to some learning material for PS scripting?
Copy link to clipboard
Copied
There are many sources, I’m betting that the following will become the “bible” on the topic:
https://www.davidebarranca.com/2019/02/professional-photoshop-scripting-v1/
Copy link to clipboard
Copied
I read something about this course a few days ago, but I would like to hear some experience about this course?
My needs are to upgrade my skills to that level so that I can create a couple of scripts as well as the extension from which I will call those scripts. I use PS in my daily work, but my experience of java scripting is poor but i am ready to develop myself in that direction. Do you think this course can help me?
Thanks in advance
Copy link to clipboard
Copied
Sign up for the free sample download a decide for yourself. Precedent for the depth and quality was set here:
https://www.htmlpanelsbook.com/
There are of course many free resources out on the web if you use some Googlefu...
Copy link to clipboard
Copied
Hi guys,
and thanks to @Stephen_A_Marsh for the kind words!
In my intentions, I wrote the Pro PS Scripting course like the one book I was craving back when I started in early 2000s (as a complete newbie), so it starts very slow and then it builds up to complex topics. I also deal with language and "programming mindset", yet you may want to look at pure JS resources along the way, to familiarize with it.
My suggestion would be to get into scripting first, and then look at HTML Panels (not the other way around). I have bundles and sample content for both books – see their websites here and here. I think it is around 100 pages combined, so well enough to get an idea about them. Feel free to get in touch directly if you need further info.
Thank you,
–Davide
Copy link to clipboard
Copied
Stephen Thank for answer the question. I do not know JavaScript I only hack at scripting Photoshop. When I don't know something I ask Google and search the Photoshop Scripting Forum. Photoshop also has a few of its own wrinkles. While there are many books on JavaScript I have the one with the rhino on the cover. Most have no information about scripting Photoshop at all. So I did not have an answer for the question. Davide book is the exception it Photoshop orientated but I don't own it. I rather send the money on wine and enjoy myself. Hacking at Photoshop scripting is something I do keep my mind a little active. My mind is simple so my scripts are simple too. When coding I always say to myself keep it simple stupid. Stupidly is bliss.