Subscribe Bookmark RSS Feed

Import Image from URL into Expression Column

robot

Community Trekker

Joined:

Feb 27, 2012

I am trying to use the new Expression Role column in JMP12 to organize some images.  I can drag an image into a cell from a webpage, but I would like to use a formula to add an image with a known URL pattern.

If I drag an image into the cell, I get a cell of the form,

New Image(Char To Blob( "   /* bunch of stuff */   ", "base64compressed" ), "jpeg")

, but this requires me to manually drag each image into the data table.  Can I add an image into a data table cell using a formula directly from the URL location?  Something like:

New Image(" http://www.sas.com/content/dam/jmp/images/design/social-share/jmp-com-share.jpg ")  // ?

1 ACCEPTED SOLUTION

Accepted Solutions
Solution

New Image(Open(URL)); seems to work.

Example:

New Table("test", Add Rows(1), New Column("Image", Expression));

:Image[1] = New Image(

    Open(

        "http://www.sas.com/content/dam/jmp/images/design/social-share/jmp-com-share.jpg "

    )

);

5 REPLIES
Solution

New Image(Open(URL)); seems to work.

Example:

New Table("test", Add Rows(1), New Column("Image", Expression));

:Image[1] = New Image(

    Open(

        "http://www.sas.com/content/dam/jmp/images/design/social-share/jmp-com-share.jpg "

    )

);

robot

Community Trekker

Joined:

Feb 27, 2012

Thanks MS.

morenopelaez_p

Community Trekker

Joined:

Feb 24, 2015

This is fantastic! Just what I was looking for!

I am not very knowledgeable in JSL, maybe someone can help me modify the proposed script to my need...

I modified the above to import an image from my computer resulting in:

New Table("test", Add Rows(1), New Column("Image", Expression));

:Image[1] = New Image("C:\Photos\Capture.png"

);

What I would love to have is a JSL script that I can save into an existing table and that, when run, would do the following:

- Look at table variable "Location" and read the folder path of the images I will want to import. Lets say this is "C:\Photos"

- Look at column 1 and read the content of cell 1 which is the name of the first image to import. lets say this is "holiday1"

- Join the path and the image name to plug it into the above script to import the image in cell 1 of "column 2"

- Loop through all the rows to import all the images.

It sounds feasible to me, just I do not know how to script many parts of the code. I am going to start researching on how to write this but if someone gets to a solution...:)

Thanks!

msharp

Super User

Joined:

Jul 28, 2015

You don't need a loop and this is faster anyways:

dt = New Table("test", Add Rows(1),

       New Column("ImageTitle", Character, Nominal, Set Values({"Capture"})),

       New Column("Image", Expression, Formula(New Image(dt:Location || :ImageTitle || ".png")))

);

dt <<  Set Table Variable("Location", "C:\Photos\");


Image with path C:\Photos\Capture.png will be displayed in column 2 (:Image)

morenopelaez_p

Community Trekker

Joined:

Feb 24, 2015

Fantastic! That is exactly what I was looking for.

Thanks a lot for the help @msharp !