0

I need this for a scriptUI panel I am working on. I am trying to add a custom image button and the image to be part of the jsx file. Does somebody know how this kind binary string is achieved, and how do I turn a png file to string of that type '\u0089PNG....' (is it initially Base64 encoded and then another encoding, or is it an encoded Byte array):

https://i.sstatic.net/OS8oy.png

Thanks in advance!

4
  • That doesn't look like a Base64 encoding; it's just a plain binary PNG file. But why are you using a screenshot to show the code? Why not show the code itself here in the post? Commented Jan 7, 2015 at 20:03
  • Because I am trying to implement my own image and I don't know how to achieve this binary string. This is just a screenshot from a video I found. I don't have problem with creating the button itself on the panel, it's just the image data that needs to be applied Commented Jan 7, 2015 at 20:05
  • So your question really is, "how do I turn a PNG file into a string of the form "\u0089PNG etc?" That wasn't very clear. Commented Jan 7, 2015 at 20:08
  • Yes, that's what I am trying to do Commented Jan 7, 2015 at 20:09

1 Answer 1

2

I found the solution using ExtendScript Toolkit

var img = File("1.png");
img.open('r');
img.encoding = 'BINARY';
var imgstr = img.read();
img.close();

$.writeln(imgstr.toSource());

It reads the PNG image and outputs the string in the console.

Thanks!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.