Copy link to clipboard
Copied
I would like to make a Scriptui window user resizeable. I've tried by adding ,{resizeable: true} into the new window line as well as trying dialog.resizeable = true;
See my attempts:
// DIALOG
// ======
var dialog = new Window("dialog"); // , {resizeable:true}
dialog.text = "TABS test";
dialog.orientation = "column";
dialog.alignChildren = ["center", "top"];
dialog.spacing = 0;
dialog.margins = 2;
dialog.resizeable = true;
// TPANEL1
// =======
var tpanel1 = dialog.add("tabbedpanel", undefined, undefined, { name: "tpanel1" });
tpanel1.alignChildren = "fill";
tpanel1.preferredSize.width = 240;
tpanel1.spacing = 10;
tpanel1.margins = 0;
// TAB1
// ====
var tab1 = tpanel1.add("tab", undefined, undefined, { name: "tab1" });
tab1.text = "Tab1";
tab1.orientation = "row";
tab1.alignChildren = ["left", "top"];
tab1.spacing = 0;
tab1.margins = 0;
var button1 = tab1.add("button", undefined, undefined, { name: "button1" });
button1.text = "Button1";
var button2 = tab1.add("button", undefined, undefined, { name: "button2" });
button2.text = "Button2";
// TAB2
// ====
var tab2 = tpanel1.add("tab", undefined, undefined, { name: "tab2" });
tab2.text = "Tab2";
tab2.orientation = "column";
tab2.alignChildren = ["left", "top"];
tab2.spacing = 0;
tab2.margins = 0;
var button3 = tab2.add("button", undefined, undefined, { name: "button3" });
button3.text = "Button3";
var button4 = tab2.add("button", undefined, undefined, { name: "button4" });
button4.text = "Button4";
// TPANEL1
// =======
tpanel1.selection = tab1;
dialog.show();
I don't see the little dotted triangle at the lower right corner as one does in windows 10.
RONC
// DIALOG
// ======
var dialog = new Window("dialog", "", undefined, {resizeable: true} );
dialog.text = "TABS test";
dialog.orientation = "column";
//dialog.alignChildren = ["fill", "top"];
dialog.alignChildren = ["fill", "fill"];
dialog.spacing = 0;
dialog.margins = 2;
// TPANEL1
// =======
var tpanel1 = dialog.add("tabbedpanel", undefined, undefined, { name: "tpanel1" });
tpanel1.alignChildren = "fill";
tpanel1.preferredSize.width = 240;
tpanel1.spacing = 10;
tpanel1.margins = 0;
// TAB1
//
...
Copy link to clipboard
Copied
in cs6 works with 16 bit
Copy link to clipboard
Copied
Does this image work in latest Photoshop as well?
Copy link to clipboard
Copied
does not work in 2020, nor in 2018.
Copy link to clipboard
Copied
Now I'm sure I didn't mess anything in code. Hmm but what causes it doesn't work in later Ps's?
Copy link to clipboard
Copied
With that file, it works in ESTK but image is not square.
I get an error in PS21.1: Error -33: Internal error
- Internal error. Line: 22 -> d.b3 = add("iconbutton", undefined, iconFile);
I processed from png to txt using my code that is up on this site.
RONC
Copy link to clipboard
Copied
So it's even worse when converted to .txt code, as it gives erorr. Probably something bad is with file.
Copy link to clipboard
Copied
I said that the file is 16 bits. For it to work, convert it to 8 bits.
Copy link to clipboard
Copied
Oh right, I had to resave it 🙂 So not only CS6 works with 16 bits, latest release as well, because provided image is there pixelated as well as opposed to ESTK? Is there chance to have the same effect like in ToolKit?
Copy link to clipboard
Copied
r-bin,
Something is wrong with the 16 bit png file.
I converted file to 8 bit png with Export in PS and then made txt. It worked in ESTK but got an error in PS.
I converted file to 8 bit png with Save to Web in PS and then made txt. This works OK in both ESTK and PS.
RONC
Copy link to clipboard
Copied
var file = new File("C:\\1\\11.png"); // 8 bit- png file
file.open("r");
file.encoding = "BINARY";
var b_img = file.read(); // the string
file.close();
var b_img1 = ScriptUI.newImage(b_img,b_img,b_img,b_img); // alt variant
///....
d.b2 = add("iconbutton", undefined, file, {style: "button"} );
d.b3 = add("iconbutton", undefined, b_img, {style: "button"} );
d.b4 = add("iconbutton", undefined, b_img1, {style: "button"} );
///....
offtopic
What you will not find if you dig.
Who knows about such an element as "editnumber"?
I just dug it (does not work in CS6).
This is a real calculator that understands both formulas with brackets and with a degree.
Copy link to clipboard
Copied
r-bin,
This is my version of what we are discussing:
var d = new Window("dialog", "", undefined, { resizeable: true });
d.orientation = "column";
d.spacing = 10;
d.margins = 10;
d.b1 = d.add("button", undefined, "B1")
d.b1.alignment = ["center", "top"];
with (d.add("panel"))
{
alignment = ["fill", "fill"];
alignChildren = ["fill", "fill"];
d.b2 = add("button", undefined, "B2");
var iconFile = "\u0089PNG\r\n\x1A\n\x00\x00\x00\rIHDR\x00\x00\x00(\x00\x00\x00(\b\x03\x00\x00\x00\u00BB H_\x00\x00\x00\x19tEXtSoftware\x00Adobe ImageReadyq\u00C9e<\x00\x00\x03#iTXtXML:com.adobe.xmp\x00\x00\x00\x00\x00<?xpacket begin=\"\u00EF\u00BB\u00BF\" id=\"W5M0MpCehiHzreSzNTczkc9d\"?> <x:xmpmeta xmlns:x=\"adobe:ns:meta/\" x:xmptk=\"Adobe XMP Core 5.6-c148 79.164036, 2019/08/13-01:06:57 \"> <rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"> <rdf:Description rdf:about=\"\" xmlns:xmp=\"http://ns.adobe.com/xap/1.0/\" xmlns:xmpMM=\"http://ns.adobe.com/xap/1.0/mm/\" xmlns:stRef=\"http://ns.adobe.com/xap/1.0/sType/ResourceRef#\" xmp:CreatorTool=\"Adobe Photoshop 21.1 (Windows)\" xmpMM:InstanceID=\"xmp.iid:727D317E5E6211EAAEB4FAC83E9C5F97\" xmpMM:DocumentID=\"xmp.did:727D317F5E6211EAAEB4FAC83E9C5F97\"> <xmpMM:DerivedFrom stRef:instanceID=\"xmp.iid:727D317C5E6211EAAEB4FAC83E9C5F97\" stRef:documentID=\"xmp.did:727D317D5E6211EAAEB4FAC83E9C5F97\"/> </rdf:Description> </rdf:RDF> </x:xmpmeta> <?xpacket end=\"r\"?>6F\u00D2\x1C\x00\x00\x00\x06PLTE\u00BE.\x17\u00B8\x19\x00f\u00D539\x00\x00\x00@IDATx\u00DAb`\x00\x01F\x18`@\u0080\u00E1,\u00C6@\u00AC^\x06b\u00ED` \u00D6-\f\u00C4\u00BA\u0099\u0081X\u00BF1\x10\x1B\x06\f\u00C4\u0086\x15\x03\u00B1a\u00CA0B\u00D2\u00CB\u00A8\u00D8h\u009E\x19\u00CD3\u0094\u0088\x01\x04\x18\x00\t/\x02\u00D1\u009C\u00FA\x12w\x00\x00\x00\x00IEND\u00AEB`\u0082";
d.b3 = add("iconbutton", undefined, iconFile);
d.b2.alignment = ["fill", "top"];
d.b3.alignment = ["fill", "fill"];
d.b3.preferredSize = [10, 10];
d.b3.onDraw = function ()
{
try
{
this.graphics.drawImage(this.image, 0, 0, this.size.width, this.size.height);
}
catch (e)
{
alert(e);
}
}
}
d.onResizing = function ()
{
this.layout.resize();
}
d.show();
This is the png to txt file of the Export PNG from PS:
var iconFile = "\u0089PNG\r\n\x1A\n\x00\x00\x00\rIHDR\x00\x00\x00(\x00\x00\x00(\x01\x03\x00\x00\x00\u00B60*.\x00\x00\x00\x04gAMA\x00\x00\u00B1\u008F\x0B\u00FCa\x05\x00\x00\x00\x01sRGB\x00\u00AE\u00CE\x1C\u00E9\x00\x00\x00\x06PLTE\u00BE.\x17\u00B8\x19\x00f\u00D539\x00\x00\x00PIDAT\b\u00D7\u00C5\u00CD1\x11\u00C0 \x10D\u00D1\u009FIA\u0089\x04\u00A4 \u008DH\u008B\x14$PRd8v\x05P\u00A7\u00BD\u00FFf\u008F\u00F4\u00D1^\u00F2$\x1E\u00CA\u00B8\x02j\u00BF\x17:\u00AA\u00E8\u00A8B\u00B8\u00B0\\0O\u0098g\u00CC\x0B\u00E6\x15\u00F3\u0086\u00B9&\x0EC\u00E6\x03\u00F3\u00CEO\x7F7#\x1CY\u00A7\x0BU\u00BD\u00E5\x00\x00\x00\x00IEND\u00AEB`\u0082";
I think PS has PNG file problems anyway.
This is the script I use to convert a png file to a txt file.
Example of Image to Text Extendscript code
I then open the txt file in notepad and copy the the text with ctrl-a/ctrl-c. I then paste it into the script at the top of page using ctrl-v.
RONC
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
It doesn't work.
Copy link to clipboard
Copied
A better way to store an image as text is to convert to Base64. This will work regardless of text encoding.
Copy link to clipboard
Copied
try this method
var file = new File("C:\\1\\11.png"); // your png
var txt = new File("C:\\1\\11.txt"); // your txt
file.open("r");
file.encoding = "BINARY";
var b_img = file.read();
file.close();
var s = "var iconFile = String.fromCharCode(";
for (var i = 0; i < b_img.length; i++) s += (i?",":"")+b_img.charCodeAt(i);
s += ");\n";
txt.open("w");
txt.write(s);
txt.close();
Copy link to clipboard
Copied
This is what I get from PS when I try the png to text you sent using the PS Export version.
Error -33: Internal error
- Internal error. Line: 27 -> d.b3 = add("iconbutton", undefined, iconFile);
ESTK works fine.
When I use the code you sent and the Save to Web version of image both ESTK and PS 21.1 work.
My png to txt works fine except on 16 bit png input. I'm trying to find how to diagnose that it is 16 bit and alert the use it can't work and then cancel the run.
That 16 bit png is BAD!!!
RONC
Copy link to clipboard
Copied
Copy link to clipboard
Copied
If you remember just a few days ago we came up with method for mt CALC to use images for the buttons. The png to txt script is for that. The method in the script is documented previously so I'm going to keep it.
Here's the link again: __SC-Save.zip
The header of the png Export file is wrong from looking at a dump. Adobe has png problems in PS. That has been documented and yelled about since Export replaced Save to Web.
RONC
Copy link to clipboard
Copied
Number encircled is bits per pixel which should be 8.
I will check for it in the png to txt script so others won't get bit by that byte!!
Enough discussion on this file.
RONC
Copy link to clipboard
Copied
I wanted to suggest to find it this way as well. Good you found it yourself 😉
Copy link to clipboard
Copied
r-bin,
Question about your code for the image to text transformation. Does what is done in it work for jpg as well as png? Grayscale and indexed png? Does mine do the same? I don't think anything can handle all of the png formats.
RONC
Copy link to clipboard
Copied
Copy link to clipboard
Copied
r-bin,
Your comments "Your code contains spaces and Unicode characters.
The editor may distort the contents of the string, which will cause an error. My code contains only numbers." are correct and says I need to remove the problem.
I will merge your code into my script and re-release it which will remove the potential for the editor messing with the file.
To handle jpg and all png format would take a plugin not a script it seems. You agree?
Thanks,
RONC
Copy link to clipboard
Copied