Photoshop Scripting: How to convert psd image in base64 in jsx to send it on server
i working on photoshop plugin. want convert photoshop psd file in base64 can send on server. following code not running. 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 base64
var base64 = base64encode(buffer);
return base64;
</pre>
i guess base64encode() function not exists. don't see definition in code , photoshop script core bit old , think doesn't has built-in function that.
you google old school method base64 conversion. like: base64.js/base64.js @ master · davidchambers/base64.js · github should modifications.
or if have html panel. can send data javascript panel, use native built-in chrome function conversion (.atob) , send data back.
for sending use html panel , make ajax request or something. or use "socket" class in jsx (tcp/ip connection)
or if have public ip or if want use in lan can use connection sdk.
More discussions in Photoshop Scripting
adobe
Comments
Post a Comment