Copy link to clipboard
Copied
Hi Experts,
I Wish to know if possible to include the image data as binary inside my script instead just showing my image inside the script, for now i use the following :
//Script Path with Image
var scriptFile = new File($.fileName);
var scriptPath = scriptFile.parent.fsName;
var w = new Window ("dialog", "Testing");
var pics = w.add ("image", undefined, File (scriptPath+"/MyScriptName_.png"));
w.show ();
and the Result is this :
but this mean i have to distribute the Script + Image file (Png) in my case, and i think this is frustrating! and may cause errors if some one forget to copy the image within script folder (in same place), So Can i convert image into binary data and use it inside my script? and How? and thanks in Advance.
Hi @M.Hasanin, check out page 115 of Peter Kahrel's book on ScriptUI.
- Mark
Copy link to clipboard
Copied
Hi @M.Hasanin, check out page 115 of Peter Kahrel's book on ScriptUI.
- Mark
Copy link to clipboard
Copied
Thanks @m1b alot
I read it and Succesfully Convert my Image to Binary,, My Modified Script is :
//Script Path with Image
var scriptFile = new File($.fileName);
var scriptPath = scriptFile.parent.fsName;
//Convert the contents of the binary file to a string
var infile = File (scriptPath+"/MyScriptName_.png");
var outfile = File (scriptPath+"/MyScriptName.txt");
infile.open ("r");
infile.encoding = "binary";
var temp = infile.read();
infile.close();
outfile.open ("w");
outfile.write (temp.toSource ());
outfile.close ();