• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Photoshop Scripting: How to convert psd image in base64 in jsx to send it on server

New Here ,
Nov 17, 2016 Nov 17, 2016

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>

TOPICS
Actions and scripting

Views

1.5K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Enthusiast ,
Nov 25, 2016 Nov 25, 2016

Copy link to clipboard

Copied

LATEST

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines