Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions convert image to binary code Scripting

  • convert image to binary code Scripting

    Posted by Rainier Raydán on March 6, 2018 at 2:55 pm

    Hi guys!

    I’m trying to add an png image to my script and I do it with this method:

    res = "group{orientation:'column', alignment:['fill', 'fill'], alignChildren:['fill', 'fill'],\
    myMooco: Group{ orientation:'row', alignment:['right', 'fill'],\
    },\

    }"
    var moocoImg = File ("./MOOCO_LOGO_Script.png");
    var icon = myPanel.grp.myMooco.add ('image', undefined, moocoImg);

    It works fine but I have problems launching it with the adobe extendscript toolkit CC (if I do it via file+script+runscript it works fine). When I push the play button it gives me the error “invalid image data ” from this line:

    var icon = myPanel.grp.myMooco.add ('image', undefined, moocoImg);

    I supose it doesnt find the image for some reason. Anyway, is there a way to convert images to binary code so I can write that code to mi file and avoid inserting the png file?

    Thanks!

    Rainier Raydán replied 8 years, 2 months ago 1 Member · 1 Reply
  • 1 Reply
  • Rainier Raydán

    March 6, 2018 at 4:12 pm

    I’ve find a way!
    Using this incredible script: https://aescripts.com/file-to-binary-converter/

    You can convert the png file to a binary string.

    just copy all the code between the quotes (dont copy the (new String() ) and paste it inside a variable, then use it to embed it.

    var binaryIcon= PASTE CODE HERE ;

    var myIcon = myPanel.grp.myGroup.add ('image', undefined, binaryIcon);

    Bye!

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy