Extract String Representation of an ImageIs there a better way to get the string from New Image() than converting the expression to a string and extracting? It just feels sloppy. Arg() doesn't work with "Picture" objects.
Names Default to Here ( 1 );
g = New Image( Char To Blob( "blahblahblob", "base64compressed" ) );
f = Substr( Char( g ), Contains( Char( g ), "\!"") + 1, Contains( Char( g ), "\!", \!"base64" ) - ( Contains( Char( g ), "\!"") + 1 ) );
Automation and ScriptingRe: Extract String Representation of an ImageI figured out what to do. Here I have images in my data table dt. Pulling the value of the cell created a picture object, but I found a way around that. I kept trying to use expressions and failing. Then I remembered that parsing a string has essentially the same effect as defining an expression. Now I can fairly cleanly send images from JMP to Python.
Names Default to Here ( 1 );
r = Parse( Char( dt:Image[11] ) );
f = Arg( Arg( r, 1 ) );
h = Encode64 Blob( Char to Blob( f, "base64compressed" ) );
Python Submit( Eval Insert( "\[
import base64
import io
from PIL import Image
pic = '''☺h☺'''
imgdata = base64.standard_b64decode(pic)
img = Image.open(io.BytesIO(imgdata))
img.show()
]\", "☺"
) );
Re: Extract String Representation of an ImageI did something similar here HTML with Embedded Images (see my reply) when I wanted a static .html without the gfx folder JMP usually creates.
View more...
Names Default To Here(1);
cur_pic = New Image("$SAMPLE_IMAGES/windmap.png");
base64compressed_str = Arg(Arg(parse(Char(cur_pic)), 1), 1);
base64_str = Encode64 Blob(Gzip Uncompress(Char To Blob(base64compressed_str, "base64compressed")));
To my understanding, this should get easier for JMP's Python integration in JMP19.