Copy link to clipboard
Copied
I am working on a photoshop plugin. I want to convert the photoshop psd file in Base64 so that I can send it on my server. But this following code is not running. It gives EvalScript Error.
<pre>
var filepath = app.activeDocument.path + '/' + name + '.png';
//get file buffer
var f= new File(filepath);
f.open();
f.encoding = 'BINARY';
var buffer = f.read(f.length);
f.close();
//file buffer to base64
var base64 = base64Encode(buffer);
return base64;
</pre>
Copy link to clipboard
Copied
I guess base64Encode() function not exists. I don't see your definition in your code and Photoshop script core is a bit old and think it doesn't has built-in function for that.
You could google old school method for base64 conversion. Something like: Base64.js/base64.js at master ยท davidchambers/Base64.js ยท GitHub but you should do some modifications.
Or If you have HTML panel. Then you can send data to javascript panel, then use native built-in Chrome function for conversion (.atob) and then send data back.
For sending you also could use HTML panel and make some Ajax request or something. Or use "Socket" class in JSX (TCP/IP connection)
Or If you have public IP or If you want use it in LAN then you can use Connection SDK.