Image Serialisation

I am building a library of functions that I would like to distribute as a single JSL file.  But some of my functions reference image files.  In this blog post I will explain the process I use for serialising the image file so that it can be embedded directly into my JSL script.

Here is one of my functions:

Central to this discussion is the PNG image file called ‘assert-error’ that sits in my resources folder.

If I distribute this code as part of a JMP add-in, then I can include the resources folder as part of the add-in build.  But I don’t want to do that.  I just want a simple JSL file that other programmers can include into their projects.

My first step is to look at the img object that I am producing.  So I create a utility script:

JMP’s log window shows the result:

The entire output is long so I’ve put “…” in rather than the full text which is about 50,000 characters in length!


And this is the code that I can use to embed my image.  The string representation I get from my log window output of my utility script:

And that’s it.  Problem solved.

One thought on “Image Serialisation”

Leave a Reply

Your email address will not be published. Required fields are marked *