Copy link to clipboard
Copied
hi
I have a number of open files of different sizes and dimensions
I want a script code that brings me the dimensions and sizes of the open files and the color mode in just one alert
In the attached picture are the names of the files.. I want the sizes and color mode for these files
#target photoshop
s2t = stringIDToTypeID;
t2s = typeIDToStringID;
var len = getPropertyDesc('application', p = 'numberOfDocuments').getInteger(s2t(p)),
result = [];
for (var i = 1; i <= len; i++) {
var res = getPropertyDesc('document', p = 'resolution', i).getDouble(s2t(p))
result.push(
getPropertyDesc('document', p = 'title', i).getString(s2t(p)) +
' @ ' + Math.round(getPropertyDesc('document', p = 'zoom', i).getDouble(s2t(p)) * 100, 2) + '% ' +
getP
...
#target photoshop
var s2t = stringIDToTypeID,
t2s = typeIDToStringID,
w = new Window("dialog {text: 'Window with the open files in the program'}"),
l = w.add("listbox{preferredSize: [500, 400]}"),
b = w.add("button {text:'Ok'}", undefined, undefined, { name: "ok" });
l.onClick = function () {
if (l.items.length) {
(r = new ActionReference()).putIndex(s2t('document'), l.selection + 1);
(d = new ActionDescriptor()).putReference(s2t('null'), r);
execu
...
Is it possible to color a specific line inside the list box?
l = w.add("listbox{preferredSize: [500, 400]}")
preferredSize: [WIDTH, HEIGHT]
#target photoshop
var s2t = stringIDToTypeID,
t2s = typeIDToStringID,
w = new Window("dialog {text: 'Window with the open files in the program'}"),
l = w.add("listbox{preferredSize: [500, 400]}"),
b = w.add("button {text:'Ok'}", undefined, undefined, { name: "ok" }),
icoRed = "\u0089PNG\r\n\x1A\n\x00\x00\x00\rIHDR\x00\x00\x00
...
Copy link to clipboard
Copied
#target photoshop
s2t = stringIDToTypeID;
t2s = typeIDToStringID;
var len = getPropertyDesc('application', p = 'numberOfDocuments').getInteger(s2t(p)),
result = [];
for (var i = 1; i <= len; i++) {
var res = getPropertyDesc('document', p = 'resolution', i).getDouble(s2t(p))
result.push(
getPropertyDesc('document', p = 'title', i).getString(s2t(p)) +
' @ ' + Math.round(getPropertyDesc('document', p = 'zoom', i).getDouble(s2t(p)) * 100, 2) + '% ' +
getPropertyDesc('document', p = 'width', i).getDouble(s2t(p)) * res / 72 + 'x' +
getPropertyDesc('document', p = 'height', i).getDouble(s2t(p)) * res / 72 + 'px ' +
t2s(getPropertyDesc('document', p = 'mode', i).getEnumerationValue(s2t(p))).replace(new RegExp('Color(Enum)?'), '') + '/' +
getPropertyDesc('document', p = 'depth', i).getInteger(s2t(p))
)
}
alert(result.join('\n'))
function getPropertyDesc(target, property, idx) {
target = s2t(target);
(r = new ActionReference()).putProperty(s2t('property'), s2t(property));
idx ? r.putIndex(target, idx) : r.putEnumerated(target, s2t('ordinal'), s2t('targetEnum'));
return executeActionGet(r);
}
Copy link to clipboard
Copied
thnak you mr.jazz-y
Is it possible to have a window or screen with the open files in the program and a checkbox next to it?
When choosing a file, it will go directly to it
Because I work on too many files
Copy link to clipboard
Copied
#target photoshop
var s2t = stringIDToTypeID,
t2s = typeIDToStringID,
w = new Window("dialog {text: 'Window with the open files in the program'}"),
l = w.add("listbox{preferredSize: [500, 400]}"),
b = w.add("button {text:'Ok'}", undefined, undefined, { name: "ok" });
l.onClick = function () {
if (l.items.length) {
(r = new ActionReference()).putIndex(s2t('document'), l.selection + 1);
(d = new ActionDescriptor()).putReference(s2t('null'), r);
executeAction(s2t('select'), d, DialogModes.NO)
}
}
l.onDoubleClick = function () { w.close() }
w.onShow = function () {
var len = getPropertyDesc('application', p = 'numberOfDocuments').getInteger(s2t(p));
if (len) {
for (var i = 1; i <= len; i++) {
var res = getPropertyDesc('document', p = 'resolution', i).getDouble(s2t(p))
l.add('item',
getPropertyDesc('document', p = 'title', i).getString(s2t(p)) +
' @ ' + Math.round(getPropertyDesc('document', p = 'zoom', i).getDouble(s2t(p)) * 100, 2) + '% ' +
getPropertyDesc('document', p = 'width', i).getDouble(s2t(p)) * res / 72 + 'x' +
getPropertyDesc('document', p = 'height', i).getDouble(s2t(p)) * res / 72 + 'px ' +
t2s(getPropertyDesc('document', p = 'mode', i).getEnumerationValue(s2t(p))).replace(new RegExp('Color(Enum)?'), '') + '/' +
getPropertyDesc('document', p = 'depth', i).getInteger(s2t(p))
)
}
l.selection = getPropertyDesc('document', p = 'itemIndex').getInteger(s2t(p)) - 1
}
}
w.show();
function getPropertyDesc(target, property, idx) {
target = s2t(target);
(r = new ActionReference()).putProperty(s2t('property'), s2t(property));
idx ? r.putIndex(target, idx) : r.putEnumerated(target, s2t('ordinal'), s2t('targetEnum'));
return executeActionGet(r);
}
Copy link to clipboard
Copied
You really are a genius jazz-y
Much appreciation to you
Great job and great effort
Copy link to clipboard
Copied
I noticed a small bug and updated both examples.
Copy link to clipboard
Copied
thank you very much jazz-y
May I know how to increase the list box font size?
Copy link to clipboard
Copied
And I have another question
Is it possible to color a specific line inside the list box?
I am working on CMYK color files
I want to check all the list and if there is no color matching CMYK
It appears to me in a red color, for example, as a warning of an error
Copy link to clipboard
Copied
Is it possible to color a specific line inside the list box?
l = w.add("listbox{preferredSize: [500, 400]}")
preferredSize: [WIDTH, HEIGHT]
#target photoshop
var s2t = stringIDToTypeID,
t2s = typeIDToStringID,
w = new Window("dialog {text: 'Window with the open files in the program'}"),
l = w.add("listbox{preferredSize: [500, 400]}"),
b = w.add("button {text:'Ok'}", undefined, undefined, { name: "ok" }),
icoRed = "\u0089PNG\r\n\x1A\n\x00\x00\x00\rIHDR\x00\x00\x00\n\x00\x00\x00\n\b\x06\x00\x00\x00\u008D2\u00CF\u00BD\x00\x00\x00;IDAT\x18\u0095c\u00FCci\u00F3\u009F\u0081\b\u00C0\x02R\u00C2((\u0084W\u00E5\u00FF\u00F7\u00EF \n\u00C1\u0080\u0087\x17\u00BB\u00AA/\u009F\u00C1\x14\x131\u00D6\x0E\x15\u0085\b_C}\u0087W!(\u009C\u00F0\x02\x06\x06\x06\x00\x18\u00EF\fO\u0083\b\u00CC\u00FD\x00\x00\x00\x00IEND\u00AEB`\u0082",
icoGreen = "\u0089PNG\r\n\x1A\n\x00\x00\x00\rIHDR\x00\x00\x00\n\x00\x00\x00\n\b\x06\x00\x00\x00\u008D2\u00CF\u00BD\x00\x00\x00=IDAT\x18\u0095c\u00F4\u00DEo\u00F8\u009F\u0081\b\u00C0\x02R\"\u00C6\u00C9\u008FW\u00E5\u00AB\u00EF\x1F!\nA@\u0090\u009D\x1B\u00AB\u00A2\u00F7?\u00BF\u0082i&b\u00AC\x1D*\n\u00E1\u00BE\u0086\u00F9\x0E\u00AFBP8\u00E1\x05\f\f\f\x000\x1F\x0E\x05z4V\u0094\x00\x00\x00\x00IEND\u00AEB`\u0082";
l.onClick = function () {
if (l.items.length) {
(r = new ActionReference()).putIndex(s2t('document'), l.selection + 1);
(d = new ActionDescriptor()).putReference(s2t('null'), r);
executeAction(s2t('select'), d, DialogModes.NO)
}
}
l.onDoubleClick = function () { w.close() }
w.onShow = function () {
l.graphics.font = "Tahoma-Bold:18";
var len = getPropertyDesc('application', p = 'numberOfDocuments').getInteger(s2t(p));
if (len) {
for (var i = 1; i <= len; i++) {
var res = getPropertyDesc('document', p = 'resolution', i).getDouble(s2t(p))
l.add('item',
' ' + getPropertyDesc('document', p = 'title', i).getString(s2t(p)) +
' @ ' + Math.round(getPropertyDesc('document', p = 'zoom', i).getDouble(s2t(p)) * 100, 2) + '% ' +
getPropertyDesc('document', p = 'width', i).getDouble(s2t(p)) * res / 72 + 'x' +
getPropertyDesc('document', p = 'height', i).getDouble(s2t(p)) * res / 72 + 'px ' +
(mode = t2s(getPropertyDesc('document', p = 'mode', i).getEnumerationValue(s2t(p))).replace(new RegExp('Color(Enum)?'), '')) + '/' +
getPropertyDesc('document', p = 'depth', i).getInteger(s2t(p))
)
l.items[i - 1].image = mode == 'CMYK' ? icoGreen : icoRed
}
l.selection = getPropertyDesc('document', p = 'itemIndex').getInteger(s2t(p)) - 1
}
}
w.show();
function getPropertyDesc(target, property, idx) {
target = s2t(target);
(r = new ActionReference()).putProperty(s2t('property'), s2t(property));
idx ? r.putIndex(target, idx) : r.putEnumerated(target, s2t('ordinal'), s2t('targetEnum'));
return executeActionGet(r);
}
It would be much better if all the requirements were originally specified in the first post. We're getting further and further away from the topic title.
Copy link to clipboard
Copied
how can i convert px to cm
need code to do it please ..
Copy link to clipboard
Copied
The file resolution determines the number of pixels in 1 inch.
1 inch equals 2.54 cm.
You need to divide the number of pixels by the resolution and multiply by 2.54
I hope you can handle this task of changing the code yourself.
Copy link to clipboard
Copied
Ok thank you
Copy link to clipboard
Copied
Hello, @Mohamed Hameed you seem to have many workflow oriented scripting requests...
I can't help to wonder if it would be for your own personal use, or if it would be used in a product?
The volunteers here sure provide lots of work and knowledge...
Copy link to clipboard
Copied
First you are welcome PECourtejoie
Second, these codes are for personal use
I'm working on Photoshop and I use the actions in my work
But the actions did not do everything that was required in the workflow
And I discovered that the scripts do a very great job beyond the capabilities of the actions
My interest in it is out of personal work, not business
I'm sorry if my questions bother you
Copy link to clipboard
Copied
Questions never bother me, I was just concerned that the generosity of the excellent script makers of this forum could be exploited for profit... Sorry as well if I was curious.
Copy link to clipboard
Copied
May you do a favour to me: Nov 24, 2021
Copy link to clipboard
Copied
Copy link to clipboard
Copied
How did you know you can add .image to l.items[i - 1]?
I mean you can't see it in l.items[i - 1].reflect.properties
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Yes, I saw that, also 128th page of JavaScript Tools Guide CC.pdf from ESTK 4, where it's wrote you can check properties like: checked, expanded, image, index, selected. But when reflecting object you can see them, plus some more, but not image, why?
Copy link to clipboard
Copied
Good question, the answer to which I don't know.
Perhaps during the rendering process, it is checked whether the user has added such a property to the object.
Copy link to clipboard
Copied
You mean you can read .image after it's added? I tried it and still it's not there as property.