Skip to main content
Known Participant
March 23, 2022
Answered

illustrator script to convert the base64 into image

  • March 23, 2022
  • 1 reply
  • 4685 views

Hi All,

 

Is it poosible to convert the base64 code(from json) into image(png/jpg) using script? And need to save the converted images into local desktop.

 

Thanks

This topic has been closed for replies.
Correct answer Inventsable
Please download the attached file to view this post

1 reply

Mylenium
Legend
March 23, 2022

You could probably decode it inside a CEP panel, but there it doesn't do you any good. That's probably a taks better suited to a web browser with a respective JS library that simply renders the image as a web page from where it can be saved as an image.

 

Mylenium

Rocky@Author
Known Participant
March 23, 2022

Thanks Mylenium for the update. Could you please share any code to decode in cep panel or web browser? 


 

Rocky@Author
Known Participant
March 30, 2022

I have do some changes now its working fine. Thanks

 


Hi Inventsable,

 

I'm trying to convert image to base 64 with the below code, but it doesn't convert the code properly. Please see the below code

 

function base64_encode(file) {
  var fs = require('fs');
  var bitmap = fs.readFileSync(file, { encoding: 'base64' });
  // convert binary data to base64 encoded string
  return Buffer.from(bitmap).toString();
}

base64_encode("/Library/Application Support/Adobe/CEP/extensions/Clipboard_Image/MyImage_21-41-12.jpeg")

Please change the filepath as you want

ImageFile