Binary data into binary script

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
Yenaphe
Posts: 84
Joined: February 3rd, 2009, 6:30 pm
Location: Paris - France
Contact:

Hi everyone,

i was wondering if it is possible to embed graphics into a jsxbin file. I've got several pngs as external ressources, but to avoid any problem i'd like to put them inside the binaryfile, but i don't know how it can be done, and if it's compatible with the AE extendscript.
nab
Posts: 203
Joined: November 29th, 2005, 3:00 am
Location: Royan
Contact:

You can embed binary data in you script as an hex string. When you execute the script, the icon file (if it does not already exists) can be recreated from the hex string. So basically what you need is some binToHex() and hexToBin() functions to do the conversion.
  • for each icon file, convert binary data to hex string and write the resulting string in a text file for instance (e.g. myIconData.txt --> var hexStr = "...";)
  • insert this string in your main script
  • in the main script, check whether the icon file exists, and recreate it if necessary
For more details see this post: ps-scripts.com (you can find conversion functions in xbytor's xtools)

I will soon release new versions of my scripts, and some of them use this technique. Works pretty well ;)
Yenaphe
Posts: 84
Joined: February 3rd, 2009, 6:30 pm
Location: Paris - France
Contact:

Very very very nice Nab. Gonna have a closer look at this.
Yenaphe
Posts: 84
Joined: February 3rd, 2009, 6:30 pm
Location: Paris - France
Contact:

Quick question nab.

Is it possible to use the hex data directly within ScriptUI methods, or do i have to do the hex2bin to recreate the file and then reimport it ?
francoisgfx
Posts: 15
Joined: June 5th, 2010, 7:06 am

that is great, I was actually trying a base64 approach, but that looks great. did you guys come up with some framework for that ?
Post Reply