jazz-y
Guide
jazz-y
Guide
Activity
‎Mar 13, 2020
10:09 AM
In the channel panel click button "new channel" with alt pressed (or run a similar menu command) Menu command "save selection" receives the masking options specified in this window (if you select masked areas, then all next selections will be normal, if you select selected areas, then the selections will be inverted). To change options for an existing channel, double-click the channel thumbnail in the Channels panel or select Channel Options from the Channels panel menu.
... View more
‎Feb 21, 2020
07:59 AM
also you can return numeric arguments, if needed, or use preserved names to buttons ({name: "ok"} returns 1, {name: "cancel"} returns 2 ) if (ShowMeFirst().show() == 1) {ShowMeSecond()}
function ShowMeFirst(){
var w = new Window("dialog");
w.text = "Dialog";
w.orientation = "column";
w.alignChildren = ["center","top"];
w.spacing = 10;
w.margins = 16;
var bnt_close = w.add("button", undefined, undefined, {name: "bnt_close"});
bnt_close.text = "Close";
bnt_close.onClick = function(){w.close(1)};
return w
}
function ShowMeSecond() {
var w = new Window("dialog");
w.text = "Dialog";
w.orientation = "column";
w.alignChildren = ["center","top"];
w.spacing = 10;
w.margins = 16;
var bnt_close = w.add("button", undefined, undefined, {name: "bnt_close"});
bnt_close.text = "Close";
bnt_close.onClick = function(){w.close()};
w.show();
}
... View more
‎Feb 21, 2020
07:19 AM
call function ShowMe() outside function of first dialog ShowMeFirst()
ShowMeSecond()
function ShowMeFirst(){
var w = new Window("dialog");
w.text = "Dialog";
w.orientation = "column";
w.alignChildren = ["center","top"];
w.spacing = 10;
w.margins = 16;
var bnt_close = w.add("button", undefined, undefined, {name: "bnt_close"});
bnt_close.text = "Close";
bnt_close.onClick = function(){w.close()};
w.show();
}
function ShowMeSecond() {
var w = new Window("dialog");
w.text = "Dialog";
w.orientation = "column";
w.alignChildren = ["center","top"];
w.spacing = 10;
w.margins = 16;
var bnt_close = w.add("button", undefined, undefined, {name: "bnt_close"});
bnt_close.text = "Close";
bnt_close.onClick = function(){w.close()};
w.show();
}
... View more
‎Feb 19, 2020
11:15 AM
UPD: seems to understand - knowing the coordinates of the vertices you need to find the lengths of the sides and correlate them with the original image size transformation ratio = size / (Math.sqrt (Math.pow(x2-x1,2) + Math.pow(y2-y1,2) ))
... View more
‎Feb 19, 2020
11:01 AM
I am writing a script that adjusts the layers size and position. There are no problems with pixel layers, but there is a problem with smart objects: they can be in a document with a transformation already done, information about which is stored in the layer settings. In the smartObjectMore object, I can get information about the initial size of the layer (size) and the coordinates of the node points of the object (transform (ActionList)), but I can’t figure out how to calculate the transformation coefficient of the layer based on this data? (I'm only interested in the simplest cases of transformation without changing the proportions).
... View more
‎Feb 15, 2020
10:41 PM
Thanks. A few messages above i found some solution
... View more
‎Feb 15, 2020
02:27 PM
Checked. Got the same result. The problem is that the number of headers can vary. Please note - first I create an empty listbox with no headers (just so that the user sees the place of the object on the form). Only after parsing csv (receiving an array in this example) I determine how many headers are needed and create a listbox with this headers for a specific file - that’s why I recreate the object, and not just changing the dataset in it. Believe me, I carefully read your messages and try all the proposed options 🙂 You did not offer to remove the parent itself, but proposed to remove the object from his parent - unfortunately, this does not work as expected in that case (but works fine with any other scriptUI objects in 99% of cases). Try to run my first example and you will understand what the problem is. When only reading code without running it, it is not obvious. Anyway, thanks. I always read your comments with interest.
... View more
‎Feb 15, 2020
02:09 PM
Same result. Any other objects are deleted and created in this way normally, the problem is only in the listbox with headers. It seems i have found a solution: if put the listbox in another object (group or panel) and delete not listbox, but his parent (with creating a new one in the function), then everything works fine: #target photoshop
var parsedCSV = [["TestField1", "TestField2", "060", "070", "080", "090"], ["TestField3", "TestField4", "145"], ["TestField5", "TestField6", "361"]]
var w = new Window("dialog"),
bn = w.add("button", undefined, "test"),
grp = w.add('group'),
oldList = grp.add('listbox', [0,0,520,200])
bn.onClick = function () {
w.remove (w.children[1]) // remove parent
buildList(parsedCSV)
}
w.show ()
function buildList (list) {
var columns=0,
wordLen={}
for (var i=0; i<list.length; i++){
if (list[i].length>columns) columns = list[i].length
for (var n=0; n<list[i].length; n++){
if (wordLen[n]=undefined) {
wordLen[n] = list[i][n].length
} else {
if (list[i][n].length > wordLen[n]) wordLen[n] =list[i][n].length
}
}
}
var props = { numberOfColumns: columns, showHeaders: true, columnTitles: [], columnWidths: [] }
for (var i=0; i<columns; i++){
props.columnTitles.push(String(i+1))
props.columnWidths.push(wordLen[i]*12)
}
var grp = w.add('group'),
newList = grp.add("listbox", [0, 0, 520, 200], undefined, props)
for (var i = 0; i < list.length; i++) {
var cur = list[i]
newList.add("item", cur[0])
for (var n = 1; n < cur.length; n++) {
newList.items[i].subItems[n - 1].text = cur[n];
}
}
w.layout.layout(true)
}
... View more
‎Feb 15, 2020
01:54 PM
The problem is that the set of headers in the listbox can be changed ONLY when it is created (i.e. numberOfColumns, showHeaders, columnTitles is a creation properties). It’s not enough for me to simply clear list, I need to recreate the object itself with a different set of fields
... View more
‎Feb 15, 2020
12:52 PM
Good day! I have a script that does some work based on data from csv files. When working with a script, a user can upload several files sequentially (i.e., after finishing working with one file, I need to make it so that the user can load another without closing the script window). The csv files have a different structure and a different number of fields (this is controlled by the user) - it seemed to me convenient to show them using a listbox with headers. Before the user specifies the file, I open the form with an empty listbox object (just to reserve a place for it in the form): After reading and processing the csv file, I create a new listbox object using the buildList() function. To do this, I delete the previously created testList object from the form, then load a new one in its place. And at this moment i have a problem with ScriptUI: If I do not delete the object, then the listbox will display normally (but old instances will be preserved): It is clear that i can rewrite the function so that for each csv file a new instance of the window is loaded in which a listbox with the necessary parameters will be immediately generated, but in my case this is inconvenient for the user. I trying to understand - is this a bug of ScriptUI or am I doing something wrong? (the example is simplified, just to demonstrate the problem) #target photoshop
var parsedCSV = [["TestField1", "TestField2", "060", "070", "080", "090"], ["TestField3", "TestField4", "145"], ["TestField5", "TestField6", "361"]]
var w = new Window("dialog"),
oldList = w.add('listbox', [0,0,520,200]),
bn = w.add("button", undefined, "test")
bn.onClick = function () {
w.remove (oldList) // problem here, i'm trying also w.remove (w.children[0])
buildList(parsedCSV)
}
w.show ()
function buildList (list) {
var columns=0,
wordLen={}
for (var i=0; i<list.length; i++){
if (list[i].length>columns) columns = list[i].length
for (var n=0; n<list[i].length; n++){
if (wordLen[n]=undefined) {
wordLen[n] = list[i][n].length
} else {
if (list[i][n].length > wordLen[n]) wordLen[n] =list[i][n].length
}
}
}
var props = { numberOfColumns: columns, showHeaders: true, columnTitles: [], columnWidths: [] }
for (var i=0; i<columns; i++){
props.columnTitles.push(String(i+1))
props.columnWidths.push(wordLen[i]*12)
}
newList = w.add("listbox", [0, 0, 520, 200], undefined, props)
for (var i = 0; i < list.length; i++) {
var cur = list[i]
newList.add("item", cur[0])
for (var n = 1; n < cur.length; n++) {
newList.items[i].subItems[n - 1].text = cur[n];
}
}
w.layout.layout(true)
}
... View more
‎Feb 08, 2020
01:48 PM
Thanks. This is easier than I thought.
... View more
‎Feb 08, 2020
01:30 PM
Hello! I have a script that collects graphical files into directories, depending on the filter specified by the user. How to open any found file not in Photoshop through app.open, but through the Windows shell? I understand that this needs to be done by running an external script, but I can’t find a suitable command. I will be glad of any help
... View more
‎Jan 25, 2020
09:58 PM
2 Upvotes
Before calling this function, you must make active or select (one or more) layers. If you need to convert all layers of a document, then instead of selecting them in a loop, easier to do this: var idplacedLayerEmbedAll = stringIDToTypeID( "placedLayerEmbedAll" );
executeAction( idplacedLayerEmbedAll, undefined, DialogModes.NO );
... View more
‎Jan 23, 2020
05:58 AM
A photo looks as if you are editing and saving photos using a much wider color space (such as Adobe RGB or ProPhoto) than smartphone screen can display. Smartphones do not know how to work with color profiles, so they simply read the values of the color coordinates from the file - because of this, a color shift occurs. Change the color profile settings in photoshop to fit the capabilities of most smartphones - sRGB or display P3 is best for this (or convert in that profile before export file) - in this case, you can save most of the image colors and its perception. Below is a simple example of how this happens - the photo on the left is converted to a proPhoto profile, and the photo on the right is assigned sRGB (simulation of how this color space displays the phone)
... View more
‎Jan 22, 2020
06:27 AM
1 Upvote
You really could use the custom names of colors in your functions in some situations - they are created as additional properties of the object and you can use them inside your code. However, when it comes to calling the DOM functions of Photoshop, you need to put the values into own properties of the SolidColor object, which writes from small letter
... View more
‎Jan 22, 2020
12:31 AM
3 Upvotes
Document.exportDocument (exportIn: File , exportAs: ExportType , options: ExportOptions ) First argument must be File (full path with filename). Folder to export this file must be created before. var png = new ExportOptionsSaveForWeb();
png.PNG8 = false;
png.transparency = true;
png.interlaced = false;
png.quality = 100;
png.includeProfile = false;
png.format = SaveDocumentType.PNG;
// save png file in PNG folder in parent directory
var exportFolder = Folder ((app.activeDocument.path.parent) + "/PNG")
if (!exportFolder.exists) exportFolder.create ()
app.activeDocument.exportDocument (File(exportFolder + "/" + app.activeDocument.name + ".png"),ExportType.SAVEFORWEB, png )
... View more
‎Jan 21, 2020
01:08 PM
2 Upvotes
Before i accidentally added unnecessary elements to the solution of the original formula: Y = x ^ (1 / G). In numerical form it can be represented much easier: Y = ((154/255)^(1/0,46))*255 = 85.12
If we need to find G from the equation Y = x ^ (1 / G), then it will take the following form: G = LOG(X)/LOG(Y). In numerical form it can be represented as: G = LOG(154/255)/LOG(85/255) = 0.459
Here is the link to google sheets: sample
1. Value from gamma
Input (X)
154
Gamma (G)
0,46
Output (Y)
85,19437485
2. Gamma from value
Input (X)
200
Value (Y)
220
Gamma (G)
1,645575473
... View more
‎Jan 21, 2020
08:25 AM
2 Upvotes
I do not remember 🙂 Many years ago I read a book on the operation of CRT-displays and there was an example of signal conversion with this (or similar) function. It was used both for display on the screen and for encoding the brightness levels in the file.This was explained as close adaptation to the characteristics of human vision. Then I noticed that it is identical to the one used in the level, curves toos and exposure in camera raw - since then it’s in my head 🙂
May be there - The rehabilitation of gamma (but most likely not)
... View more
‎Jan 21, 2020
04:20 AM
2 Upvotes
This is the gamma-compensation function: x ^ (1 / gamma). It uses to describe how human perceives a different values of brightness * gamma is the coefficient you see in the panel * all brightness values should be reduced to relative (0-255)/255 for example = 154 - (154-((154/255)^(1/0,46)*255)) = 85,19 * I don’t know why there is a difference in rounding - most likely Adobe uses a rougher calculation to speed it up. To check, you can try on other values of the coefficients: 0,17: 154 - (154-((154/255)^(1/0,17)*255)) = 13,12 2.76: 154 - (154-((154/255)^(1/2,76)*255)) = 212,41 etc..
... View more
‎Jan 15, 2020
02:41 PM
1 Upvote
First you must record (or add in action set) at least one action with least 1 command with dialog mode to use this feature.
... View more
‎Jan 15, 2020
02:32 PM
1 Upvote
Example of layer enumeration with Action Manager. Subdirectories are formed using the DOM functions (it can be done through Action Manager, but more code is needed). I did not write the export function - it can be taken from the Event Listener, passing the path to the folder and file name as input parameters. For an best result, you need to check all layers not only by name, but also by type, leaving adjustment layers (if they are located above the desired layer within the same group)) #target photoshop
// define the start index (depends of a background layer in the document)
var ref = new ActionReference()
ref.putProperty(s2t("property"), s2t("hasBackgroundLayer"))
ref.putEnumerated(s2t("document"), s2t("ordinal"), s2t("targetEnum"))
var from = executeActionGet(ref).getBoolean(s2t("hasBackgroundLayer")) ? 0 : 1
//get the total number of layers (including hidden layerSectionEnd layers)
var ref = new ActionReference()
ref.putProperty(s2t("property"), s2t("numberOfLayers"))
ref.putEnumerated(s2t("document"), s2t("ordinal"), s2t("targetEnum"))
var len = executeActionGet(ref).getInteger(s2t("numberOfLayers"));
var markedLrs = []
//check the name of each layer
for (var i = from; i <= len; i++) {
// do not check group names, but make it visible
ref = new ActionReference();
ref.putProperty(s2t("property"), s2t("layerSection"))
ref.putIndex(s2t("layer"), i)
if (t2s(executeActionGet(ref).getEnumerationValue(s2t("layerSection"))) != "layerSectionContent") {
layerVisibilityByIndex (i, true)
continue;
}
// get and check the name of the layer
ref = new ActionReference();
ref.putProperty(s2t("property"), s2t("name"))
ref.putIndex(s2t("layer"), i)
var lrName = executeActionGet(ref).getString(s2t("name"))
if (lrName.match(/\[e\]/ig)) markedLrs.push({ name: lrName.replace(/\[e\]? /ig, ""), index: i })
// hide the layer, because its visibility may interfere with our export
layerVisibilityByIndex(i, false)
}
// variables to describe the save path and file extension
fld = "~/desktop",
ext = "jpg";
for (var i = 0; i < markedLrs.length; i++) {
// select and make layer visible
selectLayerByIndex(markedLrs[i].index)
layerVisibilityByIndex(markedLrs[i].index, true)
// build the full save path
alert("exort current layer to:\n" + new File(fld + "/" + getGroupPath(markedLrs[i].index) + "/" + markedLrs[i].name + "." + ext).fsName)
// hide current layer
layerVisibilityByIndex(markedLrs[i].index, false)
}
// function that receives subdirectories based on group names
function getGroupPath() {
var lrParent = activeDocument.activeLayer.parent
var pth = []
do {
if (lrParent != activeDocument && lrParent.name.match(/\[e\]/ig)) {
pth.unshift(lrParent.name.replace(/\[e\]? /ig, ""))
lrParent = lrParent.parent
}
else { break; }
} while (true)
return pth.join('/')
}
// select layer by its index
function selectLayerByIndex(idx) {
var desc = new ActionDescriptor()
var ref = new ActionReference()
ref.putIndex(s2t("layer"), idx)
desc.putReference(s2t("null"), ref)
executeAction(s2t("select"), desc, DialogModes.NO)
}
// hide or show layer by its index
function layerVisibilityByIndex(idx, makeVisible) {
makeVisible = makeVisible == true ? "show" : "hide"
var desc = new ActionDescriptor()
var ref = new ActionReference()
ref.putIndex(s2t("layer"), idx)
desc.putReference(s2t("null"), ref)
executeAction(s2t(makeVisible), desc, DialogModes.NO);
}
function s2t(s) { return stringIDToTypeID(s) }
function t2s(t) { return typeIDToStringID(t) }
... View more
‎Jan 14, 2020
10:50 PM
1 Upvote
Now problem is that capitalization = TextCase.ALLCAPS does not really change the case of letters - it changes only the style of their display (essentially it an effect that draws over the text, like any other function from the characters palette ). TextItem.contents string does not change. To really change case of letters, you need to change the case in textItem.contents using .toUpperCase activeDocument.activeLayer.textItem.contents = activeDocument.activeLayer.textItem.contents.toUpperCase()
activeDocument.activeLayer.textItem.font = "GoodMorning" activeDocument.activeLayer.textItem.capitalization = TextCase.ALLCAPS
activeDocument.activeLayer.textItem.font = "GoodMorning" activeDocument.activeLayer.textItem.capitalization = TextCase.ALLCAPS
activeDocument.activeLayer.textItem.font = "GoodMorning"
alert (activeDocument.activeLayer.textItem.contents)
... View more
‎Jan 14, 2020
11:45 AM
The problem is with the font - it contains glyphs only for CAPITAL letters. Convert textItem contents string toUpperCase() before changing font in that case.
... View more
‎Jan 10, 2020
09:29 AM
1 Upvote
CS3 slower too (i got about 25 sec).. Result of CS2 it rahter anomaly 🙂
... View more
‎Jan 09, 2020
01:07 PM
1 Upvote
...speed is also not the last factor...
... View more
‎Jan 07, 2020
11:39 AM
I understand that all the basic work has already been done, the only question is how to add the name of the file (layer, if it is imported as a smart object) in the text layer? app.activeDocument.layers.getByName ("put here name of your text layer").textItem.contents = app.activeDocument.activeLayer.name
... View more
‎Jan 07, 2020
09:53 AM
1 Upvote
You get localLightingAngle (i.e. angle without "use global light" option) When the "use global light" option is turned on, FX panel shown value from globalLight value of layer, i.e.: function s2t(s) {return stringIDToTypeID(s)}
var ref = new ActionReference()
ref.putEnumerated( s2t("layer"), s2t("ordinal"), s2t("targetEnum"))
$.writeln ("Global angle is turned on: " + executeActionGet(ref).getObjectValue(s2t("layerEffects")).getObjectValue (s2t("dropShadow")).getBoolean(s2t("useGlobalAngle")))
$.writeln ("Local angle of dropShadow FX: " + executeActionGet(ref).getObjectValue(s2t("layerEffects")).getObjectValue (s2t("dropShadow")).getUnitDoubleValue(s2t("localLightingAngle")))
$.writeln ("Global angle of layer FX: " + executeActionGet(ref).getUnitDoubleValue(s2t("globalAngle")))
... View more
‎Jan 06, 2020
02:23 PM
Photoshop does not give scripts access to image pixels. That is you can calculate the number of points either by indirect methods (they can be selected by color, but I don’t know the way how to divide the selection into separate objects), or save each layer as an image and give it to scripts / programs for processing outside of Photoshop.
... View more
‎Jan 06, 2020
01:10 PM
1 Upvote
I looked at the Jaroslav Bereza code and saw that it is possible to use a different approach, compatible with earlier versions of Photoshop, which may be of interest to the author of the topic. This can be briefly described by the following set of menu commands: Convert Smart Object to Linked file and save it in temp dir (if it has graphical content, that can be edited in the Photoshop environment, otherwise (if it is, for example, a vector file from AI), this command will be unavailable) -> open this file in Photoshop and work with its content as with a regular document -> close & save -> run "Embed linked" command in parent document -> delete linked file In this case, there will be no problems with the transformation and effects and at the same time we can control the contents of the smart object (without replacing it completely) (I think that it is worth voicing any working solution, maybe it will be useful to someone)
... View more
‎Jan 06, 2020
06:24 AM
In some cases using the action manager, you can edit the contents of a smart object without opening it (in particular, access the layers inside it) - unsmart script of Jaroslav Bereza Also in the latest versions of Photoshop, a useful feature appeared - convert smart object to layers (a group is created in the document with the name of the smart object and its contents in the form of layers) - this can be done in your script in one line: executeAction( stringIDToTypeID( "placedLayerConvertToLayers" )) You can perform all necessary conversions and then re-save this group as a smart object: executeAction( stringIDToTypeID( "newPlacedLayer" ))
... View more